-
-
Save Bradshaw/6489560 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 class = {} -- Since you're returning this at the end, I assume you want it local to the file | |
-- Problem is, you can only have this file run once, or otherwise remove the "local" but then you're redefining the values each time you call the file (with an ugly dofile no less) | |
local health -- This is local to the whole file | |
function class.getHealth() -- Renamed to avoid confusing, replaced ob:meth() with ob.meth() syntax because that's not how closures are used | |
return health -- This returns the value, so health is closed to the file, but can be "read" with this function | |
end | |
return class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment