1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-09 08:16:58 +02:00

Merge pull request #3181 from kanyuga/patch-1

[lua/en] Added comment on ternary wonkiness
This commit is contained in:
Divay Prakash
2018-09-08 16:51:28 +05:30
committed by GitHub

View File

@@ -62,6 +62,11 @@ if not aBoolValue then print('twas false') end
-- in C/js: -- in C/js:
ans = aBoolValue and 'yes' or 'no' --> 'no' 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 karlSum = 0
for i = 1, 100 do -- The range includes both ends. for i = 1, 100 do -- The range includes both ends.
karlSum = karlSum + i karlSum = karlSum + i