mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-18 05:59:14 +01:00
Merge pull request #3181 from kanyuga/patch-1
[lua/en] Added comment on ternary wonkiness
This commit is contained in:
commit
2d2db4821b
@ -62,6 +62,11 @@ 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 if the value returned when the condition
|
||||
-- evaluates to true is not `false` or Nil
|
||||
iAmNotFalse = (not aBoolValue) and false or true --> true
|
||||
iAmAlsoNotFalse = (not aBoolValue) and true or false --> true
|
||||
|
||||
karlSum = 0
|
||||
for i = 1, 100 do -- The range includes both ends.
|
||||
karlSum = karlSum + i
|
||||
|
Loading…
x
Reference in New Issue
Block a user