> but definitely doesn't involve defining a custom `each` method on your class...
Author here! Thanks for the feedback.
I suspected as much, and was more or less writing it to be illustrative. Though I agree I am bad at Ruby :)
Author here! Thanks for the feedback.
I suspected as much, and was more or less writing it to be illustrative. Though I agree I am bad at Ruby :)
That said, in the almost 15 years I've been doing Ruby as my preferred programming language, I think I can count the amount of times I implemented a custom `each` method on one, maybe two hands.
As an example of how `each` is idiomatic, consider the Enumerable mixin: https://ruby-doc.org/core-3.0.2/Enumerable.html if you implement `each` on your class that mixin gives you all those methods (such as select) for free.