for case let ... where
Swift ⟩ Pattern Matching ⟩ Sentence Patterns ⟩
💾 程式: Mirror.handleChildren()
⭐️ 注意: for case let ... where 加條件的方式跟 if/guard case let 不一樣❗️
// mirror of `subject`
let mirror = Mirror(reflecting: subject)
// ⭐ for case let ... where
// (pattern-match tuples + data binding + condition)
// ------------------------------------------------------
// ↱ ⭐ child.label ignored ╭── ⭐ where ───╮
for case let (_, value) in mirror.children where value is T {
// ...
}
// ⭐ for case let ... where
for case let .loaded(data) in states where data.count > 2
{ ... }
Last updated
Was this helpful?