ruby的逻辑运算符and与&&
ruby的逻辑运算符and与&&
ruby中,and与&&是有区别的,而且不在“短路”运算上。看例子:
翻资料发现ruby1.8.7有这么个说法:
Use &&/|| for boolean expressions, and/or for control flow. (Rule of thumb: If you have to use outer parentheses, you are using the wrong operators.)
ruby中,and与&&是有区别的,而且不在“短路”运算上。看例子:
puts true and false puts (true and false) puts true && false puts true & false ////~> true false false false
翻资料发现ruby1.8.7有这么个说法:
引用
Use &&/|| for boolean expressions, and/or for control flow. (Rule of thumb: If you have to use outer parentheses, you are using the wrong operators.)