local Greeting = {}
Greeting.__index = Greeting
function Greeting.new()
return setmetatable({}, Greeting)
end
-- A missing argument is nil,
-- and or replaces it with the default
function Greeting:say_goodbye(message)
message = message or "Goodbye!"
print(message)
end
function Greeting:say_hello(message)
message = message or "Hello!"
print(message)
end
local greeting = Greeting.new()
-- prints Goodbye!
greeting:say_goodbye()
-- prints Hi
greeting:say_hello("Hi")