Difference between revisions of "Str.joinsep"

From OpenEUO
Jump to: navigation, search
m (Calling Convention)
m (Usage Example)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Calling Convention ==
+
== Calling Pattern ==
 
Call
 
Call
local str = sl.str
+
  local r,c = sl.str.joinsep(sep, a1, a2[, ...])
  local r,c = str.joinsep(sep, a1, a2[, ...])
+
 
Args
 
Args
 
  sep is a string
 
  sep is a string
Line 17: Line 16:
 
  print(r)
 
  print(r)
  
  --> 'Concatenate|A|Bunch|Of|Strings'
+
  --> Concatenate|A|Bunch|Of|Strings
  
 
== Description ==
 
== Description ==
Line 30: Line 29:
 
== See Also ==
 
== See Also ==
  
* [[str]]
+
* [[str|string table]]
  
* [[join]]
+
* [[str.join]]
  
* [[sep]]
+
* [[str.sep]]
  
* [[split]]
+
* [[str.split]]
  
 
* [[select]]
 
* [[select]]

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