blazar has asked for the wisdom of the Perl Monks concerning the following question:
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($_) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [Perl 6] Object methods on the fly?
by moritz (Cardinal) on Jul 18, 2007 at 06:58 UTC | |
by TimToady (Parson) on Jul 18, 2007 at 18:27 UTC | |
by blazar (Canon) on Jul 19, 2007 at 20:29 UTC | |
by TimToady (Parson) on Jul 25, 2007 at 00:42 UTC | |
by blazar (Canon) on Jul 19, 2007 at 18:53 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |