以下代码:
p ({ table: 2, sandwich: "hamburger", drink: "cola" })
在正常的终端会话中给出以下输出ruby _filename_.rb
:
{:table=>2, :sandwich=>"hamburger", :drink=>"cola"}
在 Sublime Text 2 的控制台中使用 Command+b:
/Users/*******/Desktop/scratchpad.rb:1: odd number list for Hash
p ({ table: 2, sandwich: "hamburger", drink: "cola" })
^
/Users/*******/Desktop/scratchpad.rb:1: syntax error, unexpected ':', expecting '}'
p ({ table: 2, sandwich: "hamburger", drink: "cola" })
^
[Finished in 0.0s with exit code 1]
这是为什么?