Ruby块和不带括号的参数
我提取了简单的例子:
require 'pp'x = 1..3pp x.map do |i| {:value => i, :double => (i*2)} endpp 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}]
我认为它与运算符优先级有关。我在哪里可以找到好的解释?
慕村225694
慕尼黑8549860