Skip to content

Instantly share code, notes, and snippets.

@virullius
Created August 7, 2018 14:56
Show Gist options
  • Save virullius/28ea9387b4b719b0bac8204889a70251 to your computer and use it in GitHub Desktop.
Save virullius/28ea9387b4b719b0bac8204889a70251 to your computer and use it in GitHub Desktop.
Quick test of chainable methods in Lua (works)
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