Mercurial > hg > Members > nobuyasu > Lua
view bench/defineClass.lua @ 0:73146cb10aa5
add some files
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 01 Feb 2013 03:07:15 +0900 |
parents | |
children |
line wrap: on
line source
Dog = { name = "Jiro", age = 3, showProfile = function(self) prof = string.format("name=%s,age=%d",self.name,self.age) print(prof) end } Dog = {} Dog.new = function(name, age) local obj = {} obj.name = name obj.age = age obj.showProfile = function(self) s = string.format("[name=%s,age=%d]",self.name,self.age) print(s) end return obj end jiro = Dog.new("jiro",3) sabu = Dog.new("sabu",2) jiro:showProfile() sabu:showProfile()