Difference between revisions of "Str.joinsep"

From OpenEUO
Jump to: navigation, search
m (See Also)
m (Calling Convention)
Line 1: Line 1:
== Calling Convention ==
+
== Calling Pattern ==
 
Call
 
Call
 
  local r,c = sl.str.joinsep(sep, a1, a2[, ...])
 
  local r,c = sl.str.joinsep(sep, a1, a2[, ...])

Revision as of 15:45, 2 November 2010

Calling Pattern

Call

local r,c = sl.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