Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Basic class example
Account = {} Account.__index = Account -- Makes a new account function Account:new(balance) local self = setmetatable({}, Account) self.balance = balance return self end -- Account member functions function Account:deposit(amount) self.balance = self.balance + amount end function Account:withdraw(amount) self.balance = self.balance - amount end -- Make some new Account objects MyACC = Account:new(100) print(MyACC.balance) MyACC:withdraw(10) print(MyACC.balance) YourACC = Account:new(2) print(YourACC.balance)
run
|
edit
|
history
|
help
0
Beispiel2
Monty Hall
PAID HACK PuBG
hij
Frequency distribution of rolling a certain number on xDy
l
Conta valores acima da média - LUA
lua5.3: ...Desktop/rextester_linux_2.0/usercode/68368288/source.lua:166: unexpected symbol near '}'
Hand positions in a circle
Enums in Lua (library)