title: adding a keyword without a definition in a Ruby hash
body: <p>I have the following block which allows me to add whole entries with keyword and definition:</p>
  
  <pre><code>class Dictionary
  
    def initialize
      @d = {}
    end
  
    def entries
      @d
    end
  
    def add(entry)
      (entry).each {|k,v=nil| 
        @d[k] = v
      }
    end
  
    def keywords
      @d.keys
    end
  
  end
  </code></pre>
  
  <p>I want to be able to add a keyword without a definition (add key, but no value).  I tried setting v=nil in the block above, but it still fails.  Here is the error I get when running against Rspec:</p>
  
  <pre><code>Dictionary
    is empty when created
    can add whole entries with keyword and definition
    add keywords (without definition) (FAILED - 1)
  
  Failures:
  
    1) Dictionary add keywords (without definition)
       Failure/Error: @d.add('fish')     
       NoMethodError:
        undefined method `each' for "fish":String
     # ./11_dictionary/dictionary.rb:13:in `add'
     # ./11_dictionary/dictionary_spec.rb:27:in `block (2 levels) in &lt;top (required)&gt;' 
  </code></pre>
  
  <p>Finally, here is the rspec test it needs to pass:</p>
  
  <pre><code>it 'add keywords (without definition)' do
    @d.add('fish')
    @d.entries.should == {'fish' =&gt; nil}
    @d.keywords.should == ['fish']
  end
  </code></pre>