Open johnno1962 opened 6 years ago
I know there's a long thread about this but I feel it's worth pointing out that we have this: it's UnicodeScalar.
let x: UnicodeScalar = "x"
The proposal here would be extending that to work for plain integers if the value is known to fit in the integer, I guess.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | New Feature, LanguageFeatureRequest | |Assignee | @johnno1962 | |Priority | Medium | md5: 82dd26a9f4af318193363fdfc65d9a9dIssue Description:
It is sometimes useful to be able to express the ascii value of a character more conveniently than the existing UInt8(ascii: “a”) and now that the syntax for raw strings has taken a different direction it is suggested this be simply ‘a’ as it is in many other languages. These would be Character literals in the Swift sense, able to express any UNICODE extended grapheme cluster but if the cluster contains only a single code point it should be possible to express Swift’s integer types using this literal syntax. As examples:
let a: Int8 = ‘a’
let newline: Int8 = ‘\n’