ios swift generator 文章推荐

https://medium.com/swift-programming/sequence-beyond-primitive-iterations-in-swift-80bc2507d8cc

 

/// Return a `GeneratorType` instance whose `next` method invokes
/// `body` and returns the result.
///
/// Example:
///
///     var x = 7
///     let g = anyGenerator { x < 15 ? x++ : nil }
///     let a = Array(g) // [ 7, 8, 9, 10, 11, 12, 13, 14 ]
@warn_unused_result
public func anyGenerator<Element>(body: () -> Element?) -> AnyGenerator<Element>

 

posted @ 2015-09-22 10:43  幻化成疯  阅读(215)  评论(0编辑  收藏  举报