While reading “The Well-Grounded Rubyist”, I found this topic quite interesting.
1 | names = %w{ David Black Yukihiro Matsumoto } |
I could call enum_for
on the object from which I want the enumerator to draw its iterations.
1 | e.each { |n| n.include?('a') } #=> ["David", "Black", "Matsumoto"] |
By calling upon .each
method, I was able to allow the iterator to serve as a kind of front end to array’s select
.