Question

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" ??

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top