Ruby's && operator
问题 In PHP, this evaluates to true : $a = 1 $b = 2 var_dump($a && $b); // true In ruby, this evaluates to 2 : a = 1 b = 2 p a && b # 2 Why does ruby return the value of the last statement (when the first is true and the second one is also true) and does not return a boolean? I have two arrays and I iterate them with an external iterator: a = [1,2,3].to_enum b = [5,6,7].to_enum c = [] begin while a_next = a.next && b_next = b.next result = a_next + b_next p "a[x] + b[x] = c[x] = #{a_next} + #{b