Author Topic: Ternary Abuse  (Read 4674 times)

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Ternary Abuse
« on: October 13, 2016, 01:33:58 PM »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Ternary Abuse
« Reply #1 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;

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Ternary Abuse
« Reply #2 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.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Ternary Abuse
« Reply #3 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.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Ternary Abuse
« Reply #4 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.