Created
August 7, 2018 14:56
-
-
Save virullius/28ea9387b4b719b0bac8204889a70251 to your computer and use it in GitHub Desktop.
Quick test of chainable methods in Lua (works)
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 Thing = {} | |
Thing.list = {} | |
Thing.one = function(self) | |
table.insert(self.list, "one") | |
return self | |
end | |
Thing.two = function(self) | |
table.insert(self.list, "two") | |
return self | |
end | |
Thing.three = function(self) | |
table.insert(self.list, "three") | |
return self | |
end | |
Thing.done = function(self) | |
for _,v in pairs(self.list) do | |
print(v) | |
end | |
end | |
local a = Thing | |
a:one():two():three():done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment