Created
October 10, 2012 01:19
-
-
Save fur-q/3862572 to your computer and use it in GitHub Desktop.
stop using module() ok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local mod = require "mod" | |
print(mod.func, mod.x) | |
-- 100, function: 0xFFFFFFFF | |
print(mod.priv, priv) | |
-- nil, nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function priv(x) | |
return x * 2 | |
end | |
local mod = { | |
x = 100 | |
} | |
function mod.func(x) | |
self.x = x | |
return priv(self.x) | |
end | |
return mod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment