6 ms·
That seems more confusing, since they evaluate to the same thing. 1.9.3p392 :001 > true && 1 => 1 1.9.3p392 :002 > true and 1 => 1 1.9.
by InAnEmergency 14y ago
That seems more confusing, since they evaluate to the same thing.
1.9.3p392 :001 > true && 1
=> 1
1.9.3p392 :002 > true and 1
=> 1
1.9.3p392 :003 > false && 1
=> false
1.9.3p392 :004 > false and 1
=> false
1.9.3p392 :005 > nil && 1
=> nil
1.9.3p392 :006 > nil and 1
=> nil
Which is why explicitly checking for "true" or "false" in a conditional is unusual.