Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 328 Bytes

7 kyu - List Filtering.md

File metadata and controls

17 lines (15 loc) · 328 Bytes

Task

In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out.

Solution

def filter_list(l)
  l.reject { |x| x.is_a? String }
end

Different solution

def filter_list(l)
  l.select{|i| i.is_a?(Integer)}
end