lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, 28 Jun 2008 00:55:48 +0100
Stephen Kellett <lua@objmedia.demon.co.uk> wrote:

> I prefer Lua to JS for most things, but one thing JS (and Ruby and 
> Python, etc) does better is that in JS you can ask an object what its 
> type is and get a human readable string that makes sense ("String", 
> "Weeble", "Mouse", NASDAQPrice", etc).

function MyObj () {
  return this;
}

var a = new MyObj();
print(a);
print(typeof(a));


spidermonkey says:
[object Object]
object


can't see any "type name" here. and so does Lua. give your object
"tostring" metatmethod, and it will be fine. no magick here, no magick
there. it's only a coding discipline.