Online Snippets

How to Concatenate String and Integer in Swift

Concatenate String and Integer

Below is simple example of concatenation of String and Integer in Swift.

// This is a Integer constant
let a : Int = 5
// This is a String constant
let b : String = "My string."
print("\(a) is \(b)")

Output

5 is My string.

Concatenate two String

Below is simple example of concatenation of two String in Swift.

// This is a Integer constant
let first : String = "My name is "
// This is a String constant
let second: String = "Manish Mishra."
print(first + second)

Output

My name is Manish Mishra.