summaryrefslogtreecommitdiffhomepage
path: root/lua.html.markdown
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-09-08 16:51:28 +0530
committerGitHub <noreply@github.com>2018-09-08 16:51:28 +0530
commit2d2db4821b9b6047cac9282aa7a363b081ef13ce (patch)
treece8544eb3f39a7328d8a652c9d114a4529549a98 /lua.html.markdown
parentd13203fa1e640eeabbb639883aa12383768c450a (diff)
parent5e4079fa338040a6ee6951a61ace90e87a925159 (diff)
Merge pull request #3181 from kanyuga/patch-1
[lua/en] Added comment on ternary wonkiness
Diffstat (limited to 'lua.html.markdown')
-rw-r--r--lua.html.markdown5
1 files changed, 5 insertions, 0 deletions
diff --git a/lua.html.markdown b/lua.html.markdown
index 1e2d4366..32174a81 100644
--- a/lua.html.markdown
+++ b/lua.html.markdown
@@ -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