Reputation: 53
How to concatenate string with brackets in Swift 2
in simple i know how to concatenate the string but if i want to brackets inside the string
let a = "Hello"
let b = "World"
let first = "(a) Per Level (b)" // i want to show this output ?
output would be like this : (Hello) Per Level (World)
Upvotes: 1
Views: 3264
Reputation: 2458
Another format you can use with the latest Swift2:
let first = "(\(a)) Per Level (\(b))"
Upvotes: 4
Reputation: 54600
Try this:
let first = String(format: "(%@) Per Level (%@)", a, b)
Upvotes: 0