lua-users home
lua-l archive

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


>While fiddling with the commandline tool last night trying out various
>io operations, I noticed that if one prints out the value of a result of
>io.open, you get told it's a 'file' object.
>
>I was wondering how this is done, since currently all my userdata
>objects come out as 'userdata' which is a bit irritating.

Using a __tostring metamethod: tostring looks into metatables of userdata
and use the field __tostring if present.
--lhf