Ruby supports both && as well as and.
The basic difference between these 2 lies in their precedence order.
&& has higher preference than and.
and has lower preference than = unlike && which has higher preference than =
The major difference comes while evaluating the boolean expressions.
For ex:-
as we know = has higher preference than and, so while evaluating the below statement a is assigned as true
>> a = true and false
=> false
>> puts a
true
Now as && has higher preference than =, so firstly the expression is evaluated and then it assigned to a, thus a is set as false
>> a = true && false
=> false
>> puts a
false
0 Comment(s)