For a more minimal example, running just this code by itself:
for p,i in pairs("ssss") do print(i) end |
results in this message
in pairs line 0 (tab 0) at line 1 (tab 0) |
I got curious and checked if all()
has similar behavior. Replacing pairs()
with all()
and supplying only 1 variable results in printing the characters one after another and then printing a blank string endlessly.
Also checked count()
inside print()
to see what occurs. It returns without printing anything.
Lastly, foreach()
used with a string and print
as the function results in the same behavior as using all
.
Realistically, @biteco8, you'd want to be using ipairs("...")
, not pairs("...")
, since a string is an ordered sequence that's keyed purely by integers. Though, sadly, that doesn't work either.
That being said, I did just make a post to suggest to @zep that he return nil
for out-of-bounds string accesses, because I think that would make the almost-working all("...")
iterator that @kimiyoribaka discovered work.
[Please log in to post a comment]