Reputation: 24965
The following code:
p ({ table: 2, sandwich: "hamburger", drink: "cola" })
gives the following output in a normal terminal session with ruby _filename_.rb
:
{:table=>2, :sandwich=>"hamburger", :drink=>"cola"}
and in the console of Sublime Text 2 using 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]
Why is that?
Upvotes: 0
Views: 124
Reputation: 20125
It looks like Sublime Text might be running a Ruby version from before the foo: "bar"
Hash syntax was introduced (perhaps the OS X default Ruby).
You can verify this by running a script in Sublime Text with
p RUBY_VERSION
It should output a version 1.9 or newer.
Upvotes: 2