Swift โฉ Protocols โฉ Typecasting
// if let ... as? ... if let p = person as? Programmer { // ... } // switch ... case is ... switch person { case is Programmer: // ... case is Player: // ... default: // ... } // for ... in where ... is ... for person in people where person is Programmer { // ... }
Mastering Swift 5.3 (ch. 9, p. 173)
Last updated 2 years ago