I have two variables a
and b
. I want to compare both a
and b
to a value, say 10
.
I can do it like this:
10 == a && 10 == b
But, I was wondering if there is any way to write it in a single expression? (E.g. like a == b == 10
)
[a,b,3].all? {|x| x==10}
but in this case
[].all? {|x| x==10}
will also return 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