What's this mean?
- Started
- Last post
- 17 Responses
- zoiks
var inc = targetFrame < 100 ? 1 : 5;
I am not familiar with the "?" and the "1:5"
sorry if the question is too vague...
- B3achboy0
this = ( P ) Pronunciation Key (ths)
pron. pl. these (thz)Used to refer to the person or thing present, nearby, or just mentioned: This is my cat. These are my tools.
Used to refer to what is about to be said: Now don't laugh when you hear this.
Used to refer to the present event, action, or time: said he'd be back before this.
Used to indicate the nearer or the more immediate one: This is mine and that is yours.
- zoiks0
Great way to make friends dude. Keep up the good work. I have learned more than I could have ever expected to or anticipated; think I'll call it a day.
fin.
- mitsu0
it's called a conditional operator
it's short hand for the following expression:
var inc;
if(targetFrame
- aliendn0
its ilke an if statement without the words if or else. the result before the ":" represents the if condition met. the result after the ":" represent the else condition being met. its like short notation.
- zoiks0
why the question mark or the ratio thing (1:5)
- JamesEngage0
I'd like to know what all those things do... rather than writing half a page of code to do the other thing.
- mitsu0
var inc = targetFrame < 100 ? 1 : 5;
try that again
if (targetFrame # 100){
inc = 1;
}else{
inc = 5;
}//sub '#' for the less than sign
- aliendn0
var inc = targetFrame < 100 ? 1 : 5;
means:inc = 1 if targetFrame < 100
otherwise
inc = 5.
- zoiks0
Thanks aliendn~
is this bad code form or does it even matter... I suppose if it works, it don't matter... eh?
- zoiks0
Thanks All!!
- JamesEngage0
does doin that sort of thing process any quicker? or does it get converted to the same thing in the end anyway in terms of speed?
- B3achboy0
zoiks dude - seriously!
I'm about as technical as a dead ferret
Put it this way - it got your thread bumped and then answered
;)
Bigger picture my friend, bigger picture
- zoiks0
Thanks B3achboy... sorry for the upfront sarcasm on my part...
little grumpy this am
haven't had my balanced breakfast yet....
- B3achboy0
tis cool matey
Breakfast? Crikey - I'm off for cocktails and a night of booze
ciao bella
- zoiks0
Not sure who your're asking James, but I sure don't know...
- gabriel_pc0
it's shorthand, I don't believe it gets processed any faster, it's just a way to get simple if-then-else statements on one line for legibility.