1
0
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:
Divay Prakash 2018-09-08 16:51:28 +05:30 committed by GitHub
commit 2d2db4821b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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