nudged has asked for the wisdom of the Perl Monks concerning the following question:
I don't see how mode code ref I could make the argument.$ cat ./coderref #!/usr/bin/perl package CodeRef; { use Object::InsideOut; my @code :Field :Std( Name => 'code', Private => 1 ) :Arg(Name => 'code', Mand =>1 ) :Type(CODE_REF); sub call() { my $self = shift; my $code = $self->get_code(); return $code->(@_); } } 1; #===== package main; sub sum { my $sum =0 ; foreach my $num (@_) { $sum += $num; } return $sum; } my $cref = CodeRef->new( code => \&sum ); $ ./coderef OIO::Args error: Bad value for initializer 'code': CODE(0x9d16cc0) Usage: Initializer 'code' for class 'CodeRef' must be an object or ref + of type 'CODE_REF' Package: main File: coderef Line: 35 Trace begun at coderef line 35
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Object::InsideOut with CODE_REF constructor argument
by Corion (Patriarch) on Jul 10, 2011 at 07:08 UTC | |
by Anonymous Monk on Jul 10, 2011 at 09:32 UTC | |
by Corion (Patriarch) on Jul 10, 2011 at 09:38 UTC | |
by Anonymous Monk on Jul 10, 2011 at 09:33 UTC |