Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
as
Hakusu
l
xml panel repeater
10 Line challenge
Lua Angle Cheatsheet
Area of Sector Calculator
PAID HACK PuBG
Map generator
Reverse strings function - Lua
Please log in to post a comment.