Idiomatic way to assign if not nil?

On Sep 2, 5:00 pm, “Logan C.” [email protected] wrote:

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?

I don’t think he did any such thing. I think when he says he rewrote
it, he means just that, he rewrote it, not that it actually worked or
anything :slight_smile:

No, I did not modify ruby source (for “it is not the right thing” :).

What I did was just cleaning (DRYing) up the code. And as Logan
correctly
observed came to that ‘code’. Since it cannot be done in the way I
wrote
it by adding two methods to the foo class which did the trick.

But it looks like others are bumping into similar/same repeating
patterns,
so something like that would be nice to have :wink:

Alfred