View Single Post
  #20  
Old 11-11-2007, 05:43 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Tolnaftate2004 View Post
? separates the condition from two statements that could be made:
condition?statements;


: separates the two statements apart from one another:
statement1:statement2


All they do is tell the computer where one piece ends and another starts. Both the ? and the : need to be present for the operator to function correctly.

They can also be nested:
a?b?c:d:e is "translated" into a?(b?c:d):e
You will always have # statements = # conditions + 1.
That explains how to use them, thanks
Quote:
Originally Posted by Googi View Post
Before the ? you put a condition. If that condition is true, the code between the ? and the : is executed*. If it's not true, then the code after the : is executed.

*It would be more accurate to say that the code/content either before or after the : replaces the entire statement, but the way it's phrased above makes it easier to understand.
That explains what they do, thanks

But sometimes I see someone's script and it doesnt have a ? in it, so clearly you don't ALWAYS have to use a ?. What are examples like that and what happens in them?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote