Leser: 1
4 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; package MyClass; use Moose; has 'somearray' => ( is => 'rw', isa => 'ArrayRef[Int]'); #has 'somearray' => ( is => 'rw', isa => 'ArrayRef'); 1; package main; my @array = (1,2); print Dumper(@array); my $stuff = new MyClass(somearray => \@array); #my $stuff = new MyClass({somearray => \@array}); print Dumper($stuff);
1
2
3
4
5
6
Attribute (somearray) does not pass the type constraint (__ANON__) with 'ARRAY(0x81d3b10)' at /usr/share/perl5/Moose/Meta/Attribute.pm line 221
Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x84519c0)', 'Moose::Meta::Instance=HASH(0x8451eb8)', 'MyClass=HASH(0x8451ee8)', 'HASH(0x835c4e8)') called at /usr/share/perl5/Moose/Meta/Class.pm line 102
Moose::Meta::Class::construct_instance('Moose::Meta::Class=HASH(0x844b9cc)', 'somearray', 'ARRAY(0x81d3b10)') called at /usr/share/perl5/Class/MOP/Class.pm line 306
Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x844b9cc)', 'somearray', 'ARRAY(0x81d3b10)') called at /usr/share/perl5/Moose/Meta/Class.pm line 81
Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x844b9cc)', 'somearray', 'ARRAY(0x81d3b10)') called at /usr/share/perl5/Moose/Object.pm line 26
Moose::Object::new('MyClass', 'HASH(0x8152d48)') called at moose_test.pl line 23
[perlmonks]678651[/perlmonks]
4 Einträge, 1 Seite |