I just wondered if in Perl 6 there is a provision to specify a method on a single object, as in prototype-based languages: e.g. if I have an array @array, I'd like to know if I can define a single method, say, insert(), that would for example push its argument into @array itself if it's not already there. Something like:
# pseudo-code my @array; method @array.insert ($x) { push $_, $x if $x == none($_) }
In reply to [Perl 6] Object methods on the fly? by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |