How do I concatenate strings in Swift?

前端 未结 20 1782
梦毁少年i
梦毁少年i 2020-11-28 03:04

How to concatenate string in Swift?

In Objective-C we do like

NSString *string = @\"Swift\";
NSString *resultStr = [string stringByAppen         


        
20条回答
  •  北海茫月
    2020-11-28 04:02

    You could use SwiftString (https://github.com/amayne/SwiftString) to do this.

    "".join(["string1", "string2", "string3"]) // "string1string2string"
    " ".join(["hello", "world"]) // "hello world"
    

    DISCLAIMER: I wrote this extension

提交回复
热议问题