Ruby - Enumerable - each_with_index

  • + 2 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