Skip to content

Instantly share code, notes, and snippets.

@lfzawacki
Created January 1, 2011 21:05
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 lfzawacki/762006 to your computer and use it in GitHub Desktop.
Save lfzawacki/762006 to your computer and use it in GitHub Desktop.
#!/usr/bin/lua
do
POINT = {}
POINT.new = function(pnt, x, y)
local pt = {}
function pt.display(pnt, comment)
print(comment)
print(x)
print(y)
print("")
end
function pt.getX(pnt)
return x
end
function pt.getY(pnt)
return y
end
function pt.setX(pnt,newX)
x = newX
end
function pt.setY(pnt,newY)
y = newY
end
return pt
end
end
pul = POINT:new(1,1)
plr = POINT:new(80,25)
print(type(pul))
pul:display("Upper left.")
plr:display("Lower right.") -- This fails if you uncomment it
pul:setX(2000)
pul:display("Upper left after strongarm.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment