Use reserved keyword a enum case

From the Swift Language Guide (Naming Constants & Variables section)

If you need to give a constant or variable the same name as a reserved Swift keyword, surround the keyword with back ticks (`) when using it as a name. However, avoid using keywords as names unless you have absolutely no choice.

enum MyEnum {
  case `Self`
  case AnotherCase

and use it with or without backticks

let x: MyEnum = .Self
let y = MyEnum.`Self`

Leave a Comment