== vs &&. Is there any difference?

Hi,
I’m new to Ruby. Just started to take some online classes and now study
operators. Is there a difference if there is any between AND operator
“&&” and equality operator “==” ?

Eh … do they have anything in common?

a == b evaluates to true, if a equals b (where the meaning of “equality”
depends on the types of a and b.

a && b evaluates to b, if a would evaluate to true in a boolean context,
and evaluates to a otherwise.

Hence, 5 == 9 is false, but 5 && 9 is 9.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs