Skip to content

Instantly share code, notes, and snippets.

@marcoonroad
Created October 17, 2016 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoonroad/621c1f796eac120a00b3d5248dc47478 to your computer and use it in GitHub Desktop.
Save marcoonroad/621c1f796eac120a00b3d5248dc47478 to your computer and use it in GitHub Desktop.
local prototype = require 'prototype'
local point = prototype: clone { x = 0, y = 0, }
function point: move (x, y)
self.x = self.x + x
self.y = self.y + y
end
function point: pretty ( )
local format = "(%d, %d)"
return format: format (self.x, self.y)
end
local printable = { }
function printable: print ( )
print (self: pretty ( ))
end
local instance = point: clone { protected = false, }
local extension = instance: extend (printable)
extension: print ( )
extension: move (5, 15)
extension: print ( )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment