FYI in Perl6 (Pugs right now) you can do this as follows:
use v6; class Interesting { has $.name; method myNameIs ($name) { die "Don't tell me that I don't have a name." unless defined $name; $.name = $name; } method whoAmI () { return $.name; } } my $one = Interesting.new; $one.myNameIs('What'); my $two = Interesting.new; $two.myNameIs('Who'); my $three = Interesting.new(:name('tukatukatuka SlimShady')); say "My name is : " ~ $_.whoAmI() for ($one, $two,$three);
In reply to Re: OO doesn't seem to play nice with multiple instances
by eric256
in thread OO doesn't seem to play nice with multiple instances
by krisahoch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |