mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Fix sample code
At a later point, this guide assumes that the return value of mod2.lua is a function. This commit sets that up so it all makes sense.
This commit is contained in:
parent
d5769cecdd
commit
0ef979f937
@ -366,7 +366,13 @@ mod.sayMyName() -- error
|
|||||||
-- require's return values are cached so a file is
|
-- require's return values are cached so a file is
|
||||||
-- run at most once, even when require'd many times.
|
-- run at most once, even when require'd many times.
|
||||||
|
|
||||||
-- Suppose mod2.lua contains "print('Hi!')".
|
-- Suppose another file, mod2.lua, containing this:
|
||||||
|
print('Hi!')
|
||||||
|
return function ()
|
||||||
|
return 'foo'
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
local a = require('mod2') -- Prints Hi!
|
local a = require('mod2') -- Prints Hi!
|
||||||
local b = require('mod2') -- Doesn't print; a=b.
|
local b = require('mod2') -- Doesn't print; a=b.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user