mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 15:24:09 +03:00
Clarify self-referential local functions
The current language used implies that `local function f() ... end` does not allow f to invoke itself. This has been clarified via the addition of an example of a local function that may *not* invoke itself.
This commit is contained in:
parent
412b312c45
commit
6c53c05dcc
@ -125,6 +125,9 @@ f = function (x) return x * x end
|
||||
|
||||
-- And so are these:
|
||||
local function g(x) return math.sin(x) end
|
||||
local g = function(x) return math.xin(x) end
|
||||
-- Equivalent to local function g(x)..., except referring
|
||||
-- to g in the function body won't work as expected.
|
||||
local g; g = function (x) return math.sin(x) end
|
||||
-- the 'local g' decl makes g-self-references ok.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user