4 ms·
Including `Enumberable` and implementing `each` gets you all those other methods for "free". class Stuff include Enumerable def initialize
by werdnapk 5y ago
Including `Enumberable` and implementing `each` gets you all those other methods for "free".
class Stuff
include Enumerable
def initialize
@list = [1, 2, 3, 4]
end
def each
@list.each{ yield _1 }
end
end
- deleted 5y ago[deleted]
- gfunk911 5y agoExactly. It is an interesting idea, but it makes me question the examples when `Enumerable` does not appear in the post.