Emoji Variables in Swift #๐
Swift allows developers to specify variable names in unicode, which is very helpful if you and the rest of the developers to ever touch your code speak a non-english language which uses unicode characters:
let ไฝ ๅฅฝ = "ไฝ ๅฅฝไธ็"
It is also useful if you want to specify special constants such as
let ฯ = 3.14159
most importantly though, it allows developers to use emojis for variable names:
let ๐ถ๐ฎ = "dogcow"
let ๏ผ๐ = "Hashrocket"
NSLog(๏ผ๐)
but donโt take my word for it, read the official documentation which contains some of the above examples.
> Note: the pound sign above (๏ผ) is unicode, that is why it is allowed as part of a variable name, whereas normal # sign is not.
> P.S. to access emojis and other unicode symbols directly in the current edit field press ^โ+\ on Mac.
Tweet