From: Phrogz Date: 2007-09-02T23:45:07+09:00 Subject: Re: idiomatic way to assign if not nil? On Aug 31, 12:40 am, aalfred wrote: > Recently I had a similar problem. After some refactoring of code > I rewrote the code with two (non-existing, but very DRY operators) > > I had those two cases: > > foo = bar if !bar.nil? # (case 1) or > foo = bar if foo.nil? && !bar.nil? # (case 2) > > and rewrote them into: > > foo ??= bar # case 1 > foo !!= bar # case 2 How did you do that, given that those operators are (as you say) non- existing, and the code in your resulting code produces a syntax error (under 1.8.6, anyhow)? Did you modify the Ruby source?