A common task to do in programming is to iterate through a list and test each element in a collection. In most languages this is done exactly how you would think.
strings = ["param1", "param2", "param3"]
passed_all = true;
strings.each {|s|
passed_all = false unless s.length == 6
}
puts "Matched all" if passed_all;
However Ruby is kind enough to give us the any? method on its collections. This allows for doing the same test in more more straightforward manner.
strings = ["param1", "param2", "param3"]
if (strings.all? { |s| s.length == 6 })
puts "Matched all"
end
It also gives us an any? method too if you need to do an action if, you guess it, any item in the collection passes a test.