Today I was playing with string management and thought: "If strings now work kinda like tables, maybe pairs() can work with them", but seems that it can't...
for p, i in pairs(code) do
Note: I am on education edition
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
all() and supplying only 1 variable results in printing the characters one after another and then printing a blank string endlessly.
print() to see what occurs. It returns without printing anything.
foreach() used with a string and
Realistically, @biteco8, you'd want to be using
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]