if let ... as?

Swift โŸฉ Pattern Matching โŸฉ Sentence Patterns โŸฉ

  • let: variable binding.

  • as?: optional binding.

๐Ÿ’พ ็จ‹ๅผ๏ผš Mirror.handleChildren() ๐Ÿ‘‰ ๆฏ”่ผƒ๏ผš switch case let ... as

// โญ `if let ... as?` (optional binding)
if let resettable = child.value as? Resettable {
    resettable.reset()
}

Last updated