- or download this
class Fish {
has @.scales;
}
- or download this
class Fish {
has @!scales;
method scales () { return @!scales }
...
method gist () { … }
method Capture () { \( :@!scales ) }
}
- or download this
class Fish {
has @.scales is rw;
}
- or download this
class Fish {
has @!scales;
# v---v
...
method gist () { … }
method Capture () { \( :@!scales ) }
}
- or download this
my $fish = Fish.new;
$fish.scales = ('green','blue','yellow')
- or download this
class Fish {
has @.scales;
multi method scales () { @!scales }
...
$fish.scales('green','blue','yellow');
say $fish.scales(); # does not clear it
$fish.scales(()); # clears it
- or download this
class Fish {
has @.scales;
method scales ( |c (+@new) ) {
...
$fish.scales('green','blue','yellow');
say $fish.scales(); # does not clear it
$fish.scales(()); # clears it
- or download this
class Fish {
has @.scales;
}
...
$fish.scales = ('green','blue','yellow');
say $fish.scales();
$fish.scales = (); # clears it