0
,当我打开IRB并粘贴Hash.assoc未定义的方法“assoc命令”
h = {"colors" => ["red", "blue", "green"],
"letters" => ["a", "b", "c" ]}
h.assoc("letters") #=> ["letters", ["a", "b", "c"]]
h.assoc("foo") #=> nil
进去我总是得到消息:
NoMethodError: undefined method `assoc' for {"letters"=>["a", "b", "c"], "colors"=>["red", "blue", "green"]}:Hash
from (irb):3
from :0
尽管此代码是从http://ruby-doc.org/core/classes/Hash.html#M000760 采取了我是什么做错了?