title: How to push keys and values into an empty hash w/ Ruby?
body: <p>I have a dictionary class and want to be able to push keys (as keywords) and values (as definitions) into an empty hash with an 'add' method. I don't understand how to syntactically write that. I have included an RSPEC file too.</p>
  
  <p><strong>ruby:</strong></p>
  
  <pre><code> class Dictionary
       attr_accessor :keyword, :definition
       def entries
            @hash = {}
       end
       def add(options)
            options.map do |keyword, definition|
                 @hash[keyword.to_sym] = definition
            end
       end
   end
  </code></pre>
  
  <p><strong>Rspec:</strong></p>
  
  <pre><code> require 'dictionary'
  
     describe Dictionary do
     before do
         @d = Dictionary.new
     end
     it 'can add whole entries with keyword and definition' do
         @d.add('fish' =&gt; 'aquatic animal')
         @d.entries.should == {'fish' =&gt; 'aquatic animal'}
         @d.keywords.should == ['fish']
     end
  </code></pre>
  
  <p>Any help is appreciated. Thank you! </p>
  
  <p><strong>UPDATE:</strong>
  Thank you Dave Newton for replying. I used your code and got this error: </p>
  
  <p><strong>ERROR:</strong></p>
  
  <pre><code> *Failure/Error: @d.keywords.should == ['fish']
   NoMethodError:
   undefined method `keywords' for #&lt;Dictionary:0x007fb0c31bd458 
   @hash={"fish"=&gt;"aquatic animal"}&gt;*
  </code></pre>
  
  <p>I get a different error when I convert 'word' into a symbol using @hash[word.to_sym] = defintion</p>
  
  <pre><code> *Failure/Error: @d.entries.should == {'fish' =&gt; 'aquatic animal'}
     expected: {"fish"=&gt;"aquatic animal"}
          got: {:fish=&gt;"aquatic animal"} (using ==)
     Diff:
     @@ -1,2 +1,2 @@
     -"fish" =&gt; "aquatic animal"
     +:fish =&gt; "aquatic animal"*
  </code></pre>