Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created January 7, 2016 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krokrob/34dbac96b061306d2921 to your computer and use it in GitHub Desktop.
Save krokrob/34dbac96b061306d2921 to your computer and use it in GitHub Desktop.
# COUNT
# input : array
# output: fixnum = number of element which match with condition
array = ['Michel Polnareff', 'Michel Jonasz', 'Michel Delpech', 'Maxime Leforestier']
counter = 0
array.each do |singer|
if singer.split[1].downcase.include?("o")
counter += 1
end
end
puts counter
counter = array.count do |star|
puts last_name = star.split.last
last_name.downcase.include?("o")
end
puts counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment