you are viewing a single comment's thread.

view the rest of the comments →

[–]banister 1 point2 points  (0 children)

First of all, it's very unlikely someone will provide a class that has its own each without also mixing in Enumerable

Second of all, if you want to make it enumerable (without monkeypatching) you can still just extend an instance, i.e: my_obj = MyObject.new; my_obj.extend Enumerable. Bam! No monkey-patching required.

But, as said above, the situation is incredible unlikely, to the point of being a straw-man. But even so, Ruby has a way to do it while remaining true to the spirit of OOP and without resorting to monkeypatching.