-2

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 Answers1

1

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

Piglet
  • 27,501
  • 3
  • 20
  • 43
  • wow i didnt know that existed. you really think I didnt see that manual. i wanted someone to elaborate on that not to copy-paste it – CookieByte Sep 03 '22 at 10:55
  • 1
    @vanilla what is there to elaborate? it perfectly answers your question and your post suggests that you haven't referred to the manual. otherwise there is no reason to ask this particular question. if there is anything you don't understand about what is written in the manual you should point that out in your post and I'm happy to explain – Piglet Sep 03 '22 at 12:11