I thought I’d share a technique that I’ve known about for some time, but seems to not have gotten into the normal ruby vernacular.
This trick is the use of super in methods contained in a Module.
Evan Phoenix, super is your friend
This post was a day late, right?
Update: added the rest of the punchline sentence.
I, uhm… (Score:1)
… wow.
Context (Score:2)
His point being that most Ruby users don't think to use super in a module, since OO literature tends to condition you to think of it in the context of classes only. I've no idea if super is legal in a Java interface, for example.
When folks start blogging about techniques with super and traits as if it's something special, I'll be sure
Re: (Score:1)
Except you won’t, because Perl 6 has multiple inheritance, so for correctness it will have to be “
next”, not “super”… which is something we already [cpan.org] do [cpan.org] in Perl 5 (and for the same reason). So it’s going to be business as usual in v6.Re: (Score:1)
Why would they think to use methods in a module then?
That's irrelevant. Plenty of OO literature tends to condition people to think of polymorphism in terms of inheritance only. Plenty of OO literature is bad. Besides, little extant OO literature recommends monkeypatching (or my favorite euphemism for monkeypatching, punching grandma up the