3 ms·
I don’t really know Ruby, but I imagine that if a subclass overrides puts, then code in the base class calling puts will invoke that override instead of invokin
by layer8 2y ago
I don’t really know Ruby, but I imagine that if a subclass overrides puts, then code in the base class calling puts will invoke that override instead of invoking the pseudo-global Kernel version. In other languages, the method definition in the subclass would be irrelevant, calling the global function wouldn’t cause polymorphic method dispatch on the current object.
- Lammy 2y agoRuby has Refinements for a less-global way of doing this https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc...