Skip to content

Commit

Permalink
Fix sample code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ccjmne committed Nov 30, 2024
1 parent 2432202 commit ab1b3cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,13 @@ mod.sayMyName() -- error
-- require's return values are cached so a file is
-- 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 b = require('mod2') -- Doesn't print; a=b.
Expand Down

0 comments on commit ab1b3cd

Please sign in to comment.