Instance Method インスタンスメソッド

joined(separator:)

Returns a new string by concatenating the elements of the sequence, adding the given separator between each element. 各要素の間に与えられた分離子を加えて、シーケンスの要素を連結することによる新しい文字列を返します。

Declaration 宣言

func joined(separator: String = "") -> String
Available when Element is String. ElementStringである時に利用可能です。

Parameters パラメータ

separator

A string to insert between each of the elements in this sequence. The default separator is an empty string. このシーケンスの要素のそれぞれの間に挿入されることになる文字列。省略時の分離子は空の文字列です。

Return Value 戻り値

A single, concatenated string. 単一の、連結された文字列。

Discussion 解説

The following example shows how an array of strings can be joined to a single, comma-separated string: 以下の例は、どのように文字列からなる配列が単一の、コンマ区切りの文字列へと連結できるかを示します:


let cast = ["Vivien", "Marlon", "Kim", "Karl"]
let list = cast.joined(separator: ", ")
print(list)
// Prints "Vivien, Marlon, Kim, Karl"

See Also 参照

Splitting and Joining Elements 要素の分割と連結