What is string.len in Lua?
In Lua, the string.len() function is used to get the size of a string.
Here is a visual representation of this function:
Visual representation of the len() function
Syntax
string.len(str)
Parameters
- The function needs a string as a mandatory parameter.
Return value
- The function will return the size of the string as an integer.
Example
In this example, we will return the size of our string.
mystr = "Hello, Educative!"print(string.len(mystr))
Expected output
17