سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top