Search Results

Search found 2 results on 1 pages for 'kokogyi'.

Page 1/1 | 1 

  • Ruby Inserting Key, Value elements in Hash.

    - by kokogyi
    I want to add elements to my Hash lists, which can have more than one value. Here is my code. I don't know how I can solve it! 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 Many thanks in advance. regards, koko

    Read the article

1