I'd to reach a char from a string in corona. Basically I want to:
local mystr = "corona"
print( mystr[3] )
But it always returns nil. How can I achieve that?
I'd to reach a char from a string in corona. Basically I want to:
local mystr = "corona"
print( mystr[3] )
But it always returns nil. How can I achieve that?
Here is simple logic that I used for the same purpose. Hope this may help you:
local mystr = "corona"
local str_tbl = {}
for i=1,string.len (mystr) do
str_tbl[i] = mystr:sub(i, i)
print("Character in position "..i.."is:"..str_tbl[i])
end