Find the length of a string

Verified
Added by iNTERFACEWARE

Using # or string.len() to find the length of a string, the result is the same

Source Code
   -- find the length of a string
   local s = 'abcd'
   -- using # is the most succint - we usually use this
   trace(#s)      --> 4
   -- using len() is identical to #
   trace(s:len()) --> 4
Description
Using # or string.len() to find the length of a string, the result is the same
Usage Details

Use # or string.len() to find the length a string, the result is the same for either method. The # is basically a shorthand for the string.len() function.

How to use the snippet:

  • Paste the code into your script