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.
TweetP.S. to access emojis and other unicode symbols directly in the current edit field press ^⌘+\<space> on Mac.