更新时间:2021-11-29 03:54:12
用于定义哈希键/值对,差别取决于Ruby版本。
The syntax is for defining Hash key/value pairs, and the difference depends on the Ruby version.
在Ruby 1.8和Ruby 1.9中均支持
Supported in both Ruby 1.8 and Ruby 1.9
:foo => true
仅在Ruby 1.9中支持
Supported only in Ruby 1.9
foo: true
如果您使用Ruby 1.9进行开发,应该可能使用以下语法:
If you're developing in Ruby 1.9 you should probably use the syntax:
foo: true
,因为它似乎是社区正在进入的方向。
as it appears to be the direction the community is moving in.