Skip to main content

type

Function type 

Source
pub fn type(obj: any) -> option<string>
Expand description

Checks whether a value is a file handle.

§Parameters

  • obj: any value.

§Return value

The string "file" if obj is an open file handle, "closed file" if it is a closed file handle, or nil if it is not a file handle.

§Examples

local f = assert(io.open("notes.txt"))
print(io.type(f))       --> file
f:close()
print(io.type(f))       --> closed file
print(io.type("hi"))    --> nil