You are viewing a single comment's thread. Return to all comments →
Using map and 1 line of code:
def skip_animals(animals, skip) animals.map.with_index{|a, index| "#{index}:#{a}" if index >= skip}.compact end
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby - Enumerable - each_with_index
You are viewing a single comment's thread. Return to all comments →
Using map and 1 line of code: