title: Conditional inclusion of a key-value pair in a hash
body: <p>Can someone help me shorten the following method? I began with this, which I liked just fine:</p>
  
  <pre><code>def self.some_hash
    { "foo" =&gt; "bar" }
  end
  </code></pre>
  
  <p>Now I want to add an optional key. The tersest syntax I can think of is this:</p>
  
  <pre><code>def self.some_hash(some_key=nil)
    answer = { "foo" =&gt; "bar" }
    answer[some_key] = "yucky, long-winded syntax" if some_key
    answer
  end
  </code></pre>
  
  <p>The modified method works, but I'm dissatisfied with waste of virtual ink. Is there a way to shorten it?  I realize one could employ a ternary operator on the hash literal, but that would force (I think) the repetition the <code>"foo" =&gt; "bar"</code> pair on each branch of the condition, which is also slightly less than pristine.</p>