![]() |
Probably a basic question, but....
Ok, I've never known what this code actually does:
PHP Code:
My books don't have any explination (sp?) on that. |
Re: Probably a basic question, but....
Quote:
conditional statement ? statement executed if true : statement executed if false; I'm assuming that extra 0 stuck in there after hi is a typo? |
Re: Probably a basic question, but....
are you sure it's not
Code:
int hi = 0;Code:
int hi = 0;Code:
a ? b : c;so you could use Code:
var1 += (x>2 ? 4 : 1);it's more than just a compact way of doing if statements, as i've illustrated - you can't embed a if statement in an expression, whereas you can embed the ternary operator. |
Re: Probably a basic question, but....
Quote:
Quote:
It might make if-case statements more easier |
Re: Probably a basic question, but....
Here's another question....
I was searching through the default code for the tracking. I opened up "ifi_default.h", and saw that in the struct's, it'd have like: "unsigned int pie:1;" My question now is, does the colon take the place of the equal sign? |
Re: Probably a basic question, but....
Quote:
|
Re: Probably a basic question, but....
Quote:
I just that it was another way to assign a variable. |
Re: Probably a basic question, but....
it basically allows you to save space - you could use each of the 16 bits of an int to store a different 1/0 value, approximating a set of 16 booleans
|
| All times are GMT -5. The time now is 16:47. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi