mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
fix typos and minor improvements
This commit is contained in:
parent
506cf01c67
commit
e34431b31f
@ -58,7 +58,7 @@ foo = anUnknownVariable -- Now foo = nil.
|
|||||||
aBoolValue = false
|
aBoolValue = false
|
||||||
|
|
||||||
-- Only nil and false are falsy; 0 and '' are true!
|
-- Only nil and false are falsy; 0 and '' are true!
|
||||||
if not aBoolValue then print('twas false') end
|
if not aBoolValue then print('it was false') end
|
||||||
|
|
||||||
-- 'or' and 'and' are short-circuited.
|
-- 'or' and 'and' are short-circuited.
|
||||||
-- This is similar to the a?b:c operator in C/js:
|
-- This is similar to the a?b:c operator in C/js:
|
||||||
@ -193,7 +193,7 @@ end
|
|||||||
|
|
||||||
-- A table can have a metatable that gives the table
|
-- A table can have a metatable that gives the table
|
||||||
-- operator-overloadish behavior. Later we'll see
|
-- operator-overloadish behavior. Later we'll see
|
||||||
-- how metatables support js-prototypey behavior.
|
-- how metatables support js-prototype behavior.
|
||||||
|
|
||||||
f1 = {a = 1, b = 2} -- Represents the fraction a/b.
|
f1 = {a = 1, b = 2} -- Represents the fraction a/b.
|
||||||
f2 = {a = 2, b = 3}
|
f2 = {a = 2, b = 3}
|
||||||
@ -364,7 +364,7 @@ end)()
|
|||||||
-- locals inside mod.lua are invisible outside it.
|
-- locals inside mod.lua are invisible outside it.
|
||||||
|
|
||||||
-- This works because mod here = M in mod.lua:
|
-- This works because mod here = M in mod.lua:
|
||||||
mod.sayHello() -- Says hello to Hrunkner.
|
mod.sayHello() -- Prints: Why hello there Hrunkner
|
||||||
|
|
||||||
-- This is wrong; sayMyName only exists in mod.lua:
|
-- This is wrong; sayMyName only exists in mod.lua:
|
||||||
mod.sayMyName() -- error
|
mod.sayMyName() -- error
|
||||||
|
Loading…
Reference in New Issue
Block a user