From: "David A. Black" Date: 2004-08-20T11:51:28+09:00 Subject: Re: Shortest if Assignment Statement Hi -- On Fri, 20 Aug 2004, Zach Dennis wrote: > David A. Black wrote: > > >I'm not quite following. What's not working as you'd like exactly? > > > > > > > hsh = { '*' => '(*)' , 'a' => '(1){2}' } > val = "b" > a = hsh[ val ] or hsh['*'] #to give me, a = '(*)' > puts a > val = "a" > a = hsh[ val ] or hsh['*'] #to give me, a = '(1){2}' > puts a > > I want the fourth line to output (*) instead it gives me nil. Whoops, I fell into the irb trap :-) || binds more tightly than or, so: a = hsh[val] || hsh['*'] should give you what you want. David -- David A. Black dblack@wobblini.net