mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 15:43:58 +00:00
[lua/en] Added a note about the wonky ternary
Ternaries in lua only work if the value returned when the condition evaluates to `true` is not `false` or `Nil`.
This commit is contained in:
parent
76bb8b21f6
commit
057511f3a7
@ -62,6 +62,10 @@ if not aBoolValue then print('twas false') end
|
||||
-- in C/js:
|
||||
ans = aBoolValue and 'yes' or 'no' --> 'no'
|
||||
|
||||
-- BEWARE: this only acts as a ternary value returned when the condition is true is not `false` or Nil
|
||||
ans1 = aBoolValue and false or true --> true
|
||||
ans2 = aBoolValue and true or false --> true
|
||||
|
||||
karlSum = 0
|
||||
for i = 1, 100 do -- The range includes both ends.
|
||||
karlSum = karlSum + i
|
||||
|
Loading…
Reference in New Issue
Block a user