I'm currently using equations to enter items into a table. I then want to check if the items in v
are the same when string.reverse
and if so, print that out.
table.insert (t,#t+1,z)
for k,v in ipairs (t) do
if string.reverse(v) == v then
print (v)
end
end
end
Unfortunately, all I get back are errors with if string.reverse(v) == v then print (v) end
. I've switched the order of my reverse statement and even changed it to:
table.insert (t,#t+1,z)
for k,v in ipairs (t) do
print (string.reverse(v))
end
end
The code above will successfully print every item in my table to the screen, which is not what I want. I would like it to check each item, preferably before it places that item into my table, and if true, places it into my t{}
.
What is the proper way to check whether the items in a table spell the same when reversed and print that to screen? I continually receive the following error:
bad argument #1 to 'reverse' (string expected, got nil)