Pergunta

Supose you have the following table:

mytable = {"firstelement", "secondelement", "thirdelement" }

print (mytable [1]) 
==> firstelement

How do i make it print only the "f" from the "firstelement" ??

Foi útil?

Solução

This is a simple string operation:

print(mytable[1]:sub(1,1))

more info can be found in the Lua Users string library tutorial or String manipulation in the Lua Reference manual

Outras dicas

print( mytable[1]:sub(1, 1) )

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top