ruby - (a && b) versus (a and b) -
given :
a=true b=false
why can :
puts [a && b, || b] #[false, true]
but not
puts [a , b, or b]
syntax error, unexpected keyword_and, expecting ']' puts [a , b, or b]
apparently, operator precedence comma higher "and" lower &&.
putting parenthesis around elements works:
[(a , b), (a or b)]
Comments
Post a Comment