escape dictionary key double quotes when doing println dictionary item in Swift

前端 未结 5 758
鱼传尺愫
鱼传尺愫 2020-11-30 08:51

I\'ve been playing around with Swift, and just came across an issue. I have the following Dictionary in:

var locations:Dictionary

        
5条回答
  •  既然无缘
    2020-11-30 08:56

    I've had this problem too with interpolating strings. The best solution I found was just to split it into two lines like so:

    let location = locations["current"]
    println("current locaition is \(location)")
    

    It may be a bug with Swift. From what I found in the docs, you should be able to use \ to escape quotes.

提交回复
热议问题