Ruby allows you to do
[5,5,5].sum
=> 15
Is there anything for doing boolean arithmetic on an array like
[true, true, true].sum
=> true
[true, false, true].sum
=> false
[true, true, true].all?
will return true.
[true, false, true].all?
will return false.
Furthermore, if you want to boolean OR the values:
[true, false, true].any?
returns true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With