我想在我的哈希列表中添加元素,这些列表可以有多个值.这是我的代码.我不知道怎么解决它!
class dictionary
def initialize(publisher)
@publisher=publisher
@list=Hash.new()
end
def []=(key,value)
@list << key unless @list.has_key?(key)
@list[key] = value
end
end
dic = Dictionary.new
dic["tall"] = ["long", "word-2", "word-3"]
p dic
Run Code Online (Sandbox Code Playgroud)
提前谢谢了.
问候,
KOKO