PDA

View Full Version : : and ?


Bravo_NPC-Admin1
05-26-2001, 01:21 PM
Can someone tell me what the commands : and ? do? I have seen them in codes and they aren't documented (pretty sure).
Here is an example from a code I have:

this.speed = (this.size==1? 1 : this.size==2? 1.2: 1.5);

Thanks a bunch

WhoopA
05-26-2001, 02:25 PM
?: is a C construct similar to the if statement. Graal doesn't support it as far as I know. Syntax is thus:

(condition) ? (true-statement) : (false-statement)

The ?: construct is more compact than the if statements. That code snippet you have there? I'll expand it into if's.

if (this.size == 1) {
this.speed = 1;
} else if (this.size == 2) {
this.speed = 1.2;
} else {
this.speed = 1.5;
}

Bravo_NPC-Admin1
05-27-2001, 04:48 AM
Thanks! ^_^

Er1c
05-27-2001, 05:24 AM
? and : are supported by graal.

WhoopA
05-27-2001, 09:39 AM
Well, I'll be [danned].