From: Jeff Date: 2007-04-24T12:37:17+09:00 Subject: Re: Strange syntax sugar On Apr 23, 7:40 pm, aalfred wrote: > I've recently had to deal with lots of assignments, where most of them > looked > like those two lines: > > foo = bar if !bar.nil? # (case 1) or > foo = bar if foo.nil? && !bar.nil? # (case 2) > > (I know it could be written using 'unless', but I strongly dislike > 'unless') > I think you won't need your new sugar if you just rewrite the originals: foo = bar if bar # case 1 foo ||= bar if bar # case 2 That's the simplest and cleanest, I think. Jeff softiesonrails.com