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 採取了我是什麼做錯了?