Apple Swift programming language has this amazing feature that you can use the reserved keywords of the programming language as your variable, constant, name of the class or whatsoever. To do that, all you need to do is surround the reserved keyword with a backtick, as shown below.
let <code>var</code> = "Hello"
The above code creates a constant ‘var’ of String type having the “Hello” in it. Since Swift has this feature to infer the variable or constant automatically by detecting the kind of value going in it, it doesn’t require you to specify the type except in situations when you are sure about type of value of going in it. By ensuring the type you can be more precise with your program and avoid any overflow situations.
Another example of it would be:
var <code>var</code> = 123
Here again we have declared a variable ‘var’ with the same name as the reserved Swift keyword.
Now let’s take a closer look into the situations where we can make some mistakes while using the reserved Swift keywords.
The very first mistake would be misinterpreting the backticks (`) [You can found this symbol just below the tilt operator “~” near F1 key] with an inverted comma (‘). Try to avoid it or you will end up with such errors:
let 'var' = "Hello"
error: Expected Pattern
error: Invalid character in source file
Another common mistake would be using the reserved keywords without any backticks at all and end up with such errors:
let var = "Hello"
error:'var' cannot appear nested inside another 'var' or 'let' pattern
Meaning, you cannot use them like this. Even though Swift has this feature, it doesn’t mean that you should always use it. You will always end up with poor code and EdBinx suggests you to not to use it and avoid as much as you can.
MacBook Pro mid-2014
El Capitan Beta 5