有使用Ruby 1.9.2的新的哈希语法一个奇怪的问题。 我怎样才能把任何物体在1.9.2中的哈希键?
在1.8.7哈希它的工作原理:
a="b"
{"a" => "some",a => "another value",:a => "3rd value"}
但在1.9.2>我们不能(或怎能如果我错了吗?“)
1.9.2哈希:
{a: "some"} => {:a=>"s"} #it convert to old hash format
但
a="a"
{a: "..."} # This doesn't work
{"a": "some value"} => syntax error, unexpected '}', expecting $end
from /home/naveed/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
{1: "s"} =>
SyntaxError: (irb):11: syntax error, unexpected ':', expecting tASSOC {1: "s"}