For those of you that are unfamiliar with Lua outside of Roblox's environment, io.write
is a Lua function that takes a variable amount of arguments, and prints them to the current output file.
However, unlike print
, it does not delimit its arguments with tabs, it doesn't call tostring
on its arguments, and there is no implicit newline appending.
Here is a demonstration of io.write
io.write("Hello world") io.write("Goodbye world")
yields
Hello worldGoodbye world
It doesn't implicitly add a newline, to combat this, you would append it yourself.
io.write("Hello world\n") io.write("This is in a new line now\n")
yields
Hello world
This is in a new line now
And if write
receives a non-string, non-number argument:
io.write({})
yields an exception with the following message
bad argument #1 to 'write' (string expected, got table)
I would like to use io.write
as it would let me do this without needing to concatenate everything into a single string only to print it:
for i = 0, 19 do -- just an example io.write(i, ' ') end io.write('\n') -- blah blah blah
Output: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Also it would let me write printf ;)
-- simple google search will suffice to explain printf if you don't know how it works local function printf(s, ...) local formatted = s:format(...) io.write(formatted) return #formatted end local n = math.random(0, 9) printf("Number: %d", n)
I really just want it for the fact that it doesn't append any newlines