String.len

From Data Realms Wiki

Jump to: navigation, search

Usage

String.len returns the length of any given string.

Example:

  1. string = "Hello, world!"
  2. print(string.len(string))

Example 2:

  1. string = "Hello, world!"
  2. if string.len(string) < 5 then -- "if the length of 'string' is lesser than five, then"...
  3. print("The string's length is lesser than five.")
  4. else -- "else" or "otherwise"...
  5. print("The string's length is greater than five.")
  6. end
Personal tools