String.len

From Data Realms Wiki

Revision as of 22:05, 8 October 2011 by Doves (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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