Jump to content

Send an unknown method call: Difference between revisions

→‎{{header|Perl 6}}: demo code like other examples do
(→‎{{header|Perl 6}}: demo code like other examples do)
Line 66:
 
=={{header|Perl 6}}==
Just for the fun of it, we'll mix in an anonymous role into an integer instead of defining a class.
<lang perl6>$object."$methname"(5)</lang>
<lang perl6>my $object = 42 but role { method add-me($x) { self + $x } }
my $name = 'add-me';
<langsay perl6>$object."$methnamename"(5); # 47</lang>
The double quotes are required, by the way; without them the variable would be interpreted as a hard ref to a method.
 
=={{header|PHP}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.