3 ms·
Did u follow the Perl6 parameter role link in the article? This provides a nice example which may help.... role Greet[Str $greeting] { method greet()
by draegtun 17y ago
Did u follow the Perl6 parameter role link in the article?
This provides a nice example which may help....
role Greet[Str $greeting] {
method greet() { say $greeting }
}
class EnglishMan does Greet["Hello"] { }
class Slovak does Greet["Ahoj"] { }
class Lolcat does Greet["OH HAI"] { }
EnglishMan.new.greet(); # Hello
Slovak.new.greet(); # Ahoj
Lolcat.new.greet(); # OH HAI
http://rakudo.org/2009/01/parametric-roles.html http://rakudo.org/2009/01/parametric-roles.html
- sho 17y agoOops, didn't see your reply for a while. I'll check out the explanation - very interesting to me since I've been grappling with implementing flexible roles programmatically for a while. Thanks for the link!