Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 577 Bytes

File metadata and controls

35 lines (26 loc) · 577 Bytes

LUA

The short way

Contributed by: Dautomne_

This is the way everyone in the Programmer Nullposting group says is the best.

function isEven(num)
  return num % 2 == 0
end

The OOP way

Contributed by: daillen

OOP is the best, right?

IsEven = {}

function IsEven:new(number)
  local obj = { number = number }
  setmetatable(obj, self)
  self.__index = self
  return obj
end

function IsEven:check()
  return self.number % 2 == 0
end

isEven = IsEven:new(10)
print(isEven:check())