objcio / functional-swift

Issue repository for the Functional Swift book
http://www.objc.io/books/fpinswift
927 stars 133 forks source link

GeneratorOf vs. GeneratorType #89

Closed ole closed 8 years ago

ole commented 9 years ago

Question about the + function to append one GeneratorOfs to another:

img_0339

Is there a specific reason why you used GeneratorOf for the arguments here? Wouldn't it be better/more generic to use GeneratorType? Like this:

func +<G, E where G : GeneratorType, G.Element == E>(var first: G, var second: G) -> GeneratorOf<E> {
    return GeneratorOf {
        first.next() ?? second.next()
    }
}
chriseidhof commented 9 years ago

Yes, it's more generic... but I think the other one is a bit simpler to understand. I'll leave this open so we can ponder on it a bit more.

chriseidhof commented 8 years ago

Will be fixed in the next update.