Concatenate number with string in Swift

后端 未结 6 1493
暖寄归人
暖寄归人 2020-12-14 05:57

I need to concatenate a String and Int as below:

let myVariable: Int = 8
return \"first \" + myVariable

But it do

6条回答
  •  心在旅途
    2020-12-14 06:08

    If you want to put a number inside a string, you can just use String Interpolation:

    return "first \(myVariable)"
    

提交回复
热议问题