News for hackers. Stuff that matters.
Re:IF-less programming by alisnic on Friday December 28, 2012 @07:53AM (#4977491)
I was talking in terms of the constructs which the language can provide to avoid ifs.

> And suggests that this is better:

It depends in what terms are you thinking. A syntactic improvement is a also a benefit, isn't it?

Re:IF-less programming by tallanvor on Friday December 28, 2012 @08:05AM (#4977532)
Whether or not the second example represents a syntactic improvement is more of a personal preference. Personally, I find the first example more readable when quickly scanning code.
Re:IF-less programming by jbrains on Friday December 28, 2012 @08:24AM (#4977577)
Yes, but that's probably a matter of familiarity over clarity. This is a perfect time to use the irrationally-dreaded ternary operator.

  param = object.property.nil? ? default_value : object.property
Verbose, although less so, but reveals intent almost perfectly. Would be better if the colon were "else" or "otherwise".