Author Topic: x |= y as a conditional value?  (Read 875 times)

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
x |= y as a conditional value?
« on: August 29, 2009, 05:40:53 PM »
This works:
Code: [Select]
gitc_flags = gitc_lower_bound > 20 ? 0 : gitc_flags BOR 2

This gives an OR_EQUALS parse error:
Code: [Select]
gitc_flags = gitc_lower_bound > 20 ? 0 : gitc_flags |= 2

The other *_EQUALS appears to be likewise affected (but I only tested BAND/&= and +=).

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: x |= y as a conditional value?
« Reply #1 on: August 29, 2009, 05:49:44 PM »
EQUALS is assignment in this case.

The first is correct (if lower_bound > 20; gitc=0 else gitc=gitc|2).

The second is incorrect (you're basically saying "else gitc=gitc=gitc|2").

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: x |= y as a conditional value?
« Reply #2 on: August 29, 2009, 05:54:31 PM »
Yes, I just consulted the readme (after posting, of course) and saw the difference between | and |=.
No, I'll never learn.
Thanks anyway.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: