Swift_字符串数组.joined()、.joined(sep

2020-03-17  本文已影响0人  Eyes_cc

【使用】:通过连接序列的元素,在每个元素之间添加给定的分隔符,返回一个新字符串。

/// Returns a new string by concatenating the elements of the sequence, adding the given separator between each element.
// : 通过连接序列的元素,在每个元素之间添加给定的分隔符,返回一个新字符串。
///
/// 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"
///
/// - Parameter separator: A string to insert between each of the elements in this sequence. The default separator is an empty string.
/// - Returns: A single, concatenated string.
// : 参数分隔符:要在序列中的每个元素之间插入的字符串。默认的分隔符是空字符串。
// : -返回:单个连接的字符串。
    public func joined(separator: String = "") -> String
上一篇 下一篇

猜你喜欢

热点阅读