419 posts
Location
your hardrive
Posted 22 November 2012 - 09:41 AM
is their a conditional operator in lua just like java?
1688 posts
Location
'MURICA
Posted 22 November 2012 - 09:44 AM
If you mean comparisons in ifs:
== | is equal to
> | is greater than
< | is less than
>= | is greater than or equal to
<= | is less than or equal to
~= | is not equal to
However if you mean something like
var = (condition) ? onTrue : onFalse;
then in lua, it's
var = condition and onTrue or onFalse
1243 posts
Location
Indiana, United States
Posted 22 November 2012 - 09:46 AM
Just to add; I don't believe there is:
x++
x+=y
x--
x-=y
419 posts
Location
your hardrive
Posted 22 November 2012 - 12:17 PM
i mean like x = y ? 1 : 0
1688 posts
Location
'MURICA
Posted 22 November 2012 - 12:32 PM
then in lua, it's
var = condition and onTrue or onFalse
23 posts
Location
Equestria, TX
Posted 22 November 2012 - 12:41 PM
i mean like x = y ? 1 : 0
That's called the ternary operator.
http://codepad.org/CEtRWl6lKingdaro also showed you this.
EDIT: Isn't this shit supposed to alert me when someone posts something new? First the staff and recent thread frames are broken, now this.