in reply to [Perl 6] Object methods on the fly?
class Array is also { method insert ($self: $x){ $self.push($x) unless $self.first($x); } }
Now to return to your original question: There are are surely ways to do it, I don't know if there is a clean one. For example you could write a Role, and assign that Role to the object (I think with the but or does keyword).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [Perl 6] Object methods on the fly?
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 | |
|
Re^2: [Perl 6] Object methods on the fly?
by blazar (Canon) on Jul 19, 2007 at 18:53 UTC |