Difference between revisions of "Str.joinsep"

From OpenEUO
Jump to: navigation, search
m (Created page with "== Calling Convention == Call local r,c = s.joinsep(sep, a1, a2[, ...]) Args sep is a string a1...aN are of any type (converted to strings internally via tostring()) Results ...")
 
m (Calling Convention)
Line 1: Line 1:
 
== Calling Convention ==
 
== Calling Convention ==
 
Call
 
Call
  local r,c = s.joinsep(sep, a1, a2[, ...])
+
local str = sl.str
 +
  local r,c = str.joinsep(sep, a1, a2[, ...])
 
Args
 
Args
 
  sep is a string
 
  sep is a string

Revision as of 23:50, 1 November 2010

Calling Convention

Call

local str = sl.str
local r,c = str.joinsep(sep, a1, a2[, ...])

Args

sep is a string
a1...aN are of any type (converted to strings internally via tostring())

Results

r is a string
c is a number

Usage Example

local s = sl.str
local i = 'Bunch'
local r = s.joinsep('|', 'Concatenate', 'A', i, 'Of', 'Strings')
print(r)
--> 'Concatenate|A|Bunch|Of|Strings'

Description

Joins all string arguments after the first in order, separated by the sep string provided as the first argument, and returns the resultant string as well as the number of strings joined.

Upon Error

Joinsep fails silently. If joinsep receives only sep as an argument, then a ( '', 0 ) tuple is returned. If joinsep receives only one additional argument, then that value is converted to a string and returned along with the arg count in the result tuple.

See Also