Typo in the Opaque Types section of The Swift Programming Language book

I think there's a typo in the language guide and I'm not sure where the best place to report it is. The sentence "For example, here’s a version of flip(_:) that returns a value of protocol type instead of using an opaque return type" should I believe instead say "of a protocol type."

https://docs.swift.org/swift-book/LanguageGuide/OpaqueTypes.html#ID615

Also on the same page I think there's a typo in a sentence toward the end "You also can’t use it as constraint a generic return type because there isn’t enough information outside the function body to infer what the generic type needs to be."

I'll forward this feedback along to the authors of that material. Thank you!

3 Likes

Thanks for pointing these out! I've fixed them for the next version of the book.

1 Like

I think that one is correct as written. The function returns a value of protocol type.

I didn't make the exact change @Austin_Conlon suggested — I'm replacing it with:

For example, here's a version of flip(_:) that uses a protocol type as its return type instead of an opaque return type:

The phrase "a value of protocol type", although correct, can be a little hard to parse.

1 Like
Terms of Service

Privacy Policy

Cookie Policy