Conditional Operators

Hello everyone,
I am just coming back to Roblox development after a year break (and learning web development).
I was wondering in the time I was gone if there was a conditional operator (like in JS) of some kind released (or one released a while ago i havent noticed)? It would be very helpful for some of my stuff.

(for example):

script.Parent.Text = (value == true ? 'yes' : 'no')
1 Like

There is a conditional operator, yeah:

script.Parent.Text = (value == true and 'yes' or 'no') -- brackets optional

Slightly different than Javascript and C++ and stuff, but ultimately achieves the same outcome

2 Likes

Expanding on what @SeargentAUS said, Luau has if-then-else expressions.

script.Parent.Text = if value == true then "yes" else "no"
1 Like

Thanks (to you and @SeargentAUS), had no idea this existed :slight_smile:

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