That seems like it might be a "good practice"? Renaming self with a constant, sigil-less variable will prevent you from losing your self?
Well, on the other hand, it looks like $dog is readonly:
lass Dog {
has Str $.name;
method bark(Dog:D $dog: Int:D $x) {
say $dog.^name;
say $dog.name;
$dog = 'hello';
say "bark" for 1..$x;
}
}
Dog.new.bark(3);
--output:--
Dog
(Str)
Cannot assign to an immutable value
in method bark at b.raku line 19
in block <unit> at b.raku line 24
So is using a sigil-less variable to capture self more of a style thing? For instance, to make you notice that the variable is different from other variables? |