over 9 years ago
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
Now as && has higher preference than =, so firstly the expression is evaluated and then it assigned to a, thus a is set as false
0 Comment(s)