What is the best way to iterate an array, validate each element and then return does this array is valid in Ruby? Something like:
def arr_valid?(arr)
result = true
arr.each do |element|
result = false if
# validate element with some requirments
end
end
result
end
I think there is a lot of code for this approach above.
Use
all?, which will returntrueonly if the block istruefor all elements.