summaryrefslogtreecommitdiffhomepage
path: root/lua.html.markdown
diff options
context:
space:
mode:
authorTopher <kanjoti@gmail.com>2018-08-08 19:17:43 +0300
committerGitHub <noreply@github.com>2018-08-08 19:17:43 +0300
commit057511f3a7cf41f7fc524504a063c261c0ddf836 (patch)
treea247de4102dc6256908d6bb5d175b11d2ee5f1cf /lua.html.markdown
parent76bb8b21f62a43ffee1828ae23c62021d0d95ec3 (diff)
[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`.
Diffstat (limited to 'lua.html.markdown')
-rw-r--r--lua.html.markdown4
1 files changed, 4 insertions, 0 deletions
diff --git a/lua.html.markdown b/lua.html.markdown
index 1e2d4366..2139003a 100644
--- a/lua.html.markdown
+++ b/lua.html.markdown
@@ -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