function Foo( s ) --- check this out.. return (type(s) == "string") and string.format("[%q]", s) or string.format("[%d]", s ) end Foo(1) --- "[1]" Foo("ok") --- ["ok"] I thought that this way was working with everything ... isn't it ?