Did someone just remove the Ternary operator?!

I am fairly certain that I’v used the tenary operator many times in roblox.
Ex: humanoid.JumpPower = (humanoid.Sit) ? 0 : 50

That was just an example of what the ternary is, I never actually ran THAT particular code.
But has this been removed recently? I keep getting errors when using it.

That is Java/C/etc – not Lua. Lua’s ternary is just: JumpPower = humanoid.Sit and 0 or 50

Also, FYI languages don’t have stuff like this removed arbitrarily, so the answer to your question was pretty apparent. You could have Googled “Lua ternary operator” to make sure you were doing it right before assuming it was removed.

3 Likes

Hmm…
Well I have been doing abit of java lately… maybe that’s where I got it from…

Just make sure the middle operand is never false/nil.

I did google it but I was fairly certain Iv used it in lua…

You Googled ternary operators in Lua, but somehow didn’t see ternary operators in Lua?

I saw roblox forum posts where people claimed it didnt exist, but that post was from 2016 so I thought itd been recently removed.

Nobody would remove ternary capabilities from Lua, thats just common sense. (For a programmer)

The ternary operators you described has never existed in Lua let alone Lua 5.1 that ROBLOX uses. You’ve never used them in Lua. At all. It would of had to been in another language.

Lua is different in that a lot of others languages will have && and || as their and/or for things like if statements and ternarys having dedicated operators like ?/: while Lua just uses and/or for both.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.