Без параметров

Классы / Методы

local Greeting = {}
Greeting.__index = Greeting

function Greeting.new()
  return setmetatable({}, Greeting)
end

-- No parameters in the list: only the hidden self
function Greeting:say_goodbye()
  print("Goodbye!")
end

-- No parameters at all: not even self
function Greeting.say_hello()
  print("Hello!")
end

local greeting = Greeting.new()
-- prints Goodbye!
greeting:say_goodbye()

-- Called through the class, with a dot
-- prints Hello!
Greeting.say_hello()