in reply to Moose required creates empty object Can't locate object method "x" via package "Point"
#!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); BEGIN { package Point; use Moose; has 'x' => (isa => 'Int', is => 'rw', required => 1); has 'y' => (isa => 'Int', is => 'rw', required => 1); sub clear { my $self = shift; $self->x(0); $self->y(0); } } sub Main { print Point->new->dump; print Point->new({})->dump; print Point->new({})->x; } __END__ Attribute (x) is required at C:\perl\site\lib\Moose\Object.pm line 24 Moose::Object::new('Point') called at - line 18 main::Main at - line 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose required creates empty object Can't locate object method "x" via package "Point"
by jeffa (Bishop) on May 18, 2015 at 16:19 UTC | |
by Anonymous Monk on May 18, 2015 at 22:24 UTC | |
by Anonymous Monk on May 18, 2015 at 22:28 UTC |