I'm trying to write one line of code to tell me if there is an element in an array that meets a set of criteria and then breaks on true.
For example
I have [1,2,3,4,5,6,7,8,9,10,11,12] and I want to find the first element that is divisible by 2 and 3. I want to write a one liner that will return true as soon as it hits 6 and not process the remaining elements in the array.
I can write a for each loop and break, but I feel like there should be a way to do that in one line of code.
[...].find { |n| n % 6 == 0 }