Swift_字符串数组.joined()、.joined(separator: String = ""),得到新的字符串

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

/// 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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容