From: "Jesús Gabriel y Galán" Date: 2010-03-06T05:21:11+09:00 Subject: Re: Conditional keys in hash - out of the box? On Fri, Mar 5, 2010 at 9:07 PM, Cory Chamblin wrote: > Jesús Gabriel y Galán wrote: >> One liner: >> >> mymethod(h = {:this => 'green'} && condition ? h.merge({:that => >> 'blue'}) : h) >> > > You could also do it this way: > > method {:Apples => 1}.merge(condition ? {:Oranges => 2} : {}) Oh, good one ! That's much clearer than my one liner. I still prefer the expanded solution though. Jesus.