Outpost Universe Forums

Off Topic => General Interest => Topic started by: leeor_net on October 13, 2016, 01:33:58 PM

Title: Ternary Abuse
Post by: leeor_net on October 13, 2016, 01:33:58 PM
This was painful to read. Ouch.

http://thedailywtf.com/articles/as-the-world-ternaries
Title: Re: Ternary Abuse
Post by: Hooman on October 13, 2016, 06:06:44 PM
Lol. Bonus for adding that nonsense right next to already working code.


That kind of reminds me how new programmers tend to write:
Code: [Select]
bool flag;
if (notTerriblyComplicatedConditionExpression) {
  flag = true;
} else {
  flag = false;
}

Rather than the more compact:
Code: [Select]
bool flag = notTerriblyComplicatedConditionExpression;
Title: Re: Ternary Abuse
Post by: leeor_net on October 13, 2016, 06:57:30 PM
I'm sure I've been guilty of that sort of beginner mistake in my hay days as a fledgling programmer.
Title: Re: Ternary Abuse
Post by: Hooman on October 13, 2016, 10:59:02 PM
We've all been guilty of that one.

Was great to see the light when I first learned you could just assign like that.
Title: Re: Ternary Abuse
Post by: leeor_net on October 14, 2016, 03:51:52 PM
I remember coming up with something like that and thinking "There has to be a better way to do this" and realizing all of a sudden in that moment that I could use the expression itself as a yes or no type deal.