3 ms·
Regarding find_all_with_index, you can do: .find_all.with_index { |item, index| ... }
by Widdershin 12y ago
Regarding find_all_with_index, you can do:
.find_all.with_index { |item, index| ... }
- dragonwriter 12y agoexcept .find_all.with_index passes the index to the predicate block, but still only returns a view of the matching elements from the list. What I think is being sought is more like: module Enumerable def find_indices each.with_index .find_all {|x,_| yield x} .map {|_,y| y} end end