Jump to content

Send an unknown method call: Difference between revisions

added perl
(added perl)
Line 17:
example[name](5) # => 47</lang>
 
=={{header|Perl 6}}==
<lang perl>package Example;
<lang perl6>$object."$methname"(5)</lang>
sub new {
bless {}
}
sub foo {
my ($self, $x) = @_;
return 42 + $x;
}
package main;
my $name = "foo";
print Example->new->$name(5), "\n"; # prints "47"</lang>
 
=={{header|Python}}==
String literal "foo" may be replaced by any expression resulting in a string
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.