View Single Post
  #4   Spotlight this post!  
Unread 16-01-2004, 14:01
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Re: Probably a basic question, but....

Quote:
Originally Posted by Jay Lundy
The ? : is called the ternary operator. It's a more compact way of doing if statements. The format is:

conditional statement ? statement executed if true : statement executed if false;

I'm assuming that extra 0 stuck in there after hi is a typo?
Yea, I was typing kinda/pretty fast then.

Quote:
Originally Posted by deltacoder1020
are you sure it's not
Code:
  	int hi = 0;
 
 return hi ? 1 : 0;
what i've just written is equivalent to this:
Code:
  	int hi = 0;
 
 if(hi) return 1;
 
 else return 0;
basically, the code
Code:
 	a ? b : c;
means "replace this with b is a is true, otherwise, replace this with c"
Thanks, that really clears it up (also thanks to you Jay ).

It might make if-case statements more easier
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"