Does ruby ​​have an array summing method for boolean values?

Ruby lets you do

[5,5,5].sum => 15 

Is there anything to do boolean arithmetic in an array like

 [true, true, true].sum => true [true, false, true].sum => false 
+7
ruby boolean-logic
source share
1 answer
 [true, true, true].all? 

will return true.

 [true, false, true].all? 

will return false.

Also, if you want to log OR values:

 [true, false, true].any? 

returns true.

+20
source share

All Articles