Jump to content

Talk:Programming with Moose/Difficulties/Moose-w-Moose

Page contents not supported in other languages.
Add topic
From Wikibooks, open books for an open world
Latest comment: 17 years ago by EvanCarroll in topic Proposed solutions

Proposed solutions

[edit source]

steven's other idea with infinite recursion

package Hash; use Moose; use Moose::Util::TypeConstraints; coerce 'Hash'  => from 'HashRef'  => via { Hash->new(hash => $_) }; has 'hash' => (  is => 'rw',  isa => 'Hash',  coerce => 1,  lazy => 1,  default => sub { Hash->new } ); package main; my $h = Hash->new; $h->hash->hash({ foo => 1 }); print $h->dump; 

EvanCarroll (talk) 17:02, 3 January 2008 (UTC)Reply

Solution

[edit source]

Since this has been written, there is a solution to this issue on the CPAN: MooseX::AttributeInflate.