Greetings, wise Monks!
How do you get a ref to a method? EG, if I want a ref to Foo->new(), how do I do that? I can get a ref to Foo::new, but that doesn't do what I want. EG:
I want to do this to make my tests simpler. I want to pass a code ref to a run_test() sub.use Foo; my $new = \&Foo::new; my $obj = &$new(); # Bzzzt! without the ->, it doesn't pass the class # name as the 1st arg $new = sub { return Foo->new(@_) }; $obj = &$new(); # does what I want, but is this necessary?
In reply to Ref to Method? by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |