Neatest way to filter an array of strings by another array in ruby I have an array of strings which are file names files, and an array of allowed file types or suffixes allowed_types. I want to filter out files which don't end with an allowed suffix.

This does the trick, but I'm wondering if anyone can suggest a neater solution? Such as a way keep with ruby's usual streamlined style without using flag variables. 

valid_files = Dir.entries(path).select do |f| 
  valid = false
  allowed_types.each { |suffix| next valid = true if f.end_with? suffix }
  next valid
end
How about this?

valid_files = Dir.entries(path).select do |f| 
  allowed_types.any? {|suffix| f.end_with? suffix}
end