Expected hexadecimal code in braces after unicode escape

前端 未结 2 1659
醉酒成梦
醉酒成梦 2020-12-16 08:53

This worked in the first beta of Swift.

var degree = \"\\u00B0\" // degree symbol

Now I\'m getting this error and I don\'t understand what

2条回答
  •  不知归路
    2020-12-16 09:31

    The correct code is:

    var degree = "\u{00B0}" // degree symbol
    

    From the Xcode 6 beta 4 release notes:

    The \x, \u and \U escape sequences in string literals have been consolidated into a single and less error prone \u{123456} syntax. (17279286)

提交回复
热议问题