Mohammed Awad
Mohammed Awad

Reputation: 53

How to concatenate string with brackets in Swift 2

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

Answers (2)

Korpel
Korpel

Reputation: 2458

Another format you can use with the latest Swift2:

let first = "(\(a)) Per Level (\(b))"

Upvotes: 4

i_am_jorf
i_am_jorf

Reputation: 54600

Try this:

let first = String(format: "(%@) Per Level (%@)", a, b)

Upvotes: 0

Related Questions