I need to concatenate a String
and Int
as below:
let myVariable: Int = 8
return "first " + myVariable
But it does not compile, with the error:
Binary operator '+' cannot be applied to operands of type 'String' and 'Int'
What is the proper way to concatenate a String + Int?
If you want to put a number inside a string, you can just use String Interpolation:
return "first \(myVariable)"