From: Robert Klemme Date: 2007-04-13T21:20:07+09:00 Subject: Re: Idiom wanted (now hiring!) On 13.04.2007 13:07, Robert Dober wrote: > On 4/13/07, Robert Klemme wrote: >> On 13.04.2007 08:02, Jonathan wrote: >> > Is there a cool way to do this without calling the function twice?: >> > >> > a = func(b) unless func(b).nil? (AKA) >> > a = func(b) if func(b) >> >> Just to throw something obvious (which has not been mentioned so far) >> into the mix: >> >> x = func(b) >> a = x if x > x = func b > a ||=x > > How many combinations might we come up with ;)? Certainly a lot more. However, my main point was to simply store the result of func(b) in another variable and reuse that. Sometimes the cool solutions are not without issues (see the other postings) and a pragmatic solution can be better at times. :-) Kind regards robert