I got a situation where I want to process whole array and perform any? operation on array to check whether some elements returns false
For example:
I want to print all truth values. And I also want to check anything is false in array:
def hel?
[true, false, true].any?{|x| p x; x}
end
The above example will print only first value (i.e) true and returns true. But I want it to print all elements of array and return false. Is there some other way to do it? or any change in same thing ? Thanks 🙂
To print the values, do this:
To see if all of them are truthy, do this:
In order to do both, do this:
Or, you can put it into one iteration: