假设我有一个未着色的代码:
some_var = Hash.new
some_var[:name] = "blah"
some_var[:address] = "101 blahblah lane"
another = "Olly olly oxen free!"
什么是红宝石的方式使它漂亮?
选择1:保持原样
选项2:关联事物
some_var = Hash.new
some_var[:name] = "blah"
some_var[:address] = "101 blahblah lane"
another = "Olly olly oxen free!"
选项3:对齐所有内容
some_var = Hash.new
some_var[:name] = "blah"
some_var[:address] = "101 blahblah lane"
another = "Olly olly oxen free!"
选项4:?????
谢谢!!
最佳答案
像在您的示例中那样使用散列,我将执行另一个版本:
some_var = {
:name => "blah",
:address => "101 blahblah lane",
}
another = "Olly olly oxen free!"
或者用Ruby1.9
some_var = {
name: "blah",
address: "101 blahblah lane",
}
another = "Olly olly oxen free!"