Type Function
Library io.*
Return value String
Revision Release 2023.3686
Keywords io, type, file
See also


Checks whether obj is a valid file handle. Returns the string "file" if obj is an open file handle, "closed file" if obj is a closed file handle, or nil if obj is not a file handle.


io.type( obj )
obj (required)

Object. Object to be tested.


local fh
print( io.type( fh ) )  --> nil
local path = system.pathForFile( "Icon.png", system.ResourceDirectory )
fh = path )
print( io.type( fh ) )  --> "file"
io.close( fh )
print( io.type( fh ) )  --> "closed file"