Rect = {x = 0, y = 0, width = 10, height = 20} Rect.__index = Rect function Rect:new (o) setmetatable(o, self) return o end function Rect:area () return self.width * self.height end r1 = Rect:new {width = 40, height = 60} print(r1:area()) r2 = Rect:new {} print(r2:area()) r1.width = 3 print(r1:area()) print(r2:area())