What do the arguments "*line" and "*all" for io.read() do?

123 views Asked by At

I tried the following two codes on a test.lua file and they worked the same except for when i used '*a' i was able to type multiple lines of input.

l = io.read('*l')
print(i)
a = io.read('*a')
print(a)

I want to know if that is all to the '*a' argument and how is it any different from '*l' apart from what I have already mentioned.

Also I do my lua coding ZeroBrane if that info helps.

1

There are 1 answers

2
Piglet On

Presented by the StackOverflow manual reading service:

"*a": reads the whole file, starting at the current position. On end of file, it returns the empty string.

"*l": reads the next line skipping the end of line, returning nil on end of file. This is the default format.

From https://www.lua.org/manual/5.2/manual.html#pdf-file:read