Small Swift Tips #02: Using reserved keywords
The SmallSwiftTips on this post will show you how you can use some system reserved keywords on your code, if you ever need.
A very common example can be founded when declaring enum values. Let's imagine we have an enum and we want to have a case named "default". This is a reserved keyword so if you just try to use it, you'’l notice you can't.
Using the name between `` you'll be able to use the reserved keyword.
enum LayoutMode {
case `default`
case expanded
case detailed
}
There are a few reserved keywords that you might want to use on your code like associativity, convenience, dynamic, final, lazy, left, mutating, none, optional, override, postfix, precedence, prefix, required, right, weak.
With this tip you can use them without problems and keep the consistency on your code when naming variables, enums and so on. 😁🚀