Swift lazy subscript ignores filter
问题 How does subscripting a lazy filter work? let ary = [0,1,2,3] let empty = ary.lazy.filter { $0 > 4 }.map { $0 + 1 } print(Array(empty)) // [] print(empty[2]) // 3 It looks like it just ignores the filter and does the map anyway. Is this documented somewhere? What other lazy collections have exceptional behavior like this? 回答1: It comes down to subscripting a LazyFilterCollection with an integer which in this case ignores the predicate and forwards the subscript operation to the base. For