Skip to main content

input

Function input 

Source
pub fn input(f: option<any>) -> file
Expand description

Sets or gets the default input file.

§Parameters

  • file: a file name to open in text mode, or an already open file handle, to become the new default input file. When absent, the function only queries.

§Return value

The current default input file. When setting, raises an error if the file name cannot be opened.

§Examples

io.input("data.txt")        -- read from data.txt from now on
print(io.read("l"))         -- first line of data.txt
io.input(io.stdin)          -- back to stdin

§See also

output, io.read