In ruby 1.9 is there a way to define this hash with the new syntax?
irb> { a: 2 }
=> {:a=>2}
irb> { a-b: 2 }
SyntaxError: (irb):5: syntax error, unexpected tLABEL
{ a-b: 2 }
^
with the old one, it's working:
irb> { :"a-b" => 2 }
=> {:"a-b"=>2}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…