I was messing around, I don't normally use Ternary operators so I decided to see what all I could do with it.
Ended up making this:
x={}
x.a = true
doOne = function()
x.a = 'hi'
return 'hi'
end
doTwo = function()
x.a = 'bye'
return 'bye'
end
print(10==true and doOne() or doTwo())
print(x.a)
However in the process of making whatever that is, I realized that I can't do this:
print(10==true and x.a = "hi" or x.a = "bye")
print(x.a)
Why is that?
Since it acts somewhat like an if statement, if I do that surely nothing should go wrong, putting it in a function seems too long and there is probably a shorter way.
I tried putting a return behind it and tried using rawequal, tried using load() even though I couldn't find much documentation on it.
Is using a function the only valid solution or is there a shorter way? This could be very helpful for code golf :wedoalittletrolling:

1 comment
Excellent answer, I tried using rawset and load yesterday but it was slightly confusing since I never used them before, Thank you for making this post :o