Let's say I have something like
a = io.read()
a = tonumber(a)
if a then
print(a,a^2-1)
end
Is there another way to get this input without being io.read()
?
Let's say I have something like
a = io.read()
a = tonumber(a)
if a then
print(a,a^2-1)
end
Is there another way to get this input without being io.read()
?
Ready in the library is that right there. There are always several ways to get the same, but if you want to read from the console is the best way. Example:
local stdin = io.stdin:lines()
for line in stdin do
print(line)
end
See working on ideone and on CodingGround .
If you want to read other sources you have several other ways. You have documentation .