Difference between revisions of "Str.joinsep"

From OpenEUO
Jump to: navigation, search
m (Calling Convention)
m (Usage Example)
 
Line 16: Line 16:
 
  print(r)
 
  print(r)
  
  --> 'Concatenate|A|Bunch|Of|Strings'
+
  --> Concatenate|A|Bunch|Of|Strings
  
 
== Description ==
 
== Description ==

Latest revision as of 15:46, 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