我提取了简单的例子:
require 'pp'
x = 1..3
pp x.map do |i| {:value => i, :double => (i*2)} end
pp x.map { |i| {:value => i, :double => (i*2)} }
pp(x.map do |i| {:value => i, :double => (i*2)} end)
pp(x.map { |i| {:value => i, :double => (i*2)} })
我想知道为什么第一个 pp 产生:
[1, 2, 3]
虽然所有的订单都在给:
[{:value=>1, :double=>2}, {:value=>2, :double=>4}, {:value=>3, :double=>6}]
我认为它与运算符优先级有关。我在哪里可以找到好的解释?