We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xcode 7.3, Swift 2.2
md5: 5933d8df40f388055dd4c8c47d23ca7e
relates to:
Issue Description:
Swift currently cannot convert an array of types conforming to a protocol X to an array of [X]. It is possible to circumvent this by using `map`.
Example:
protocol AnotherThing {} struct X: AnotherThing {} let a = [X(), X(), X()] func takesX(a: [X]) -> [AnotherThing] { // Compilation of following line fails let anotherThings: [AnotherThing] = a as [AnotherThing] // This works: // let anotherThings: [AnotherThing] = a.map { $0 as AnotherThing } return anotherThings } func takesOneX(a: X) -> AnotherThing { return a }
The example project is also available on GitHub: https://github.com/Ben-G/AppleBugProjects/blob/master/ProtocolArrayTypeConversion/ProtocolArrayTypeConversion/main.swift
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Environment
Xcode 7.3, Swift 2.2
Additional Detail from JIRA
md5: 5933d8df40f388055dd4c8c47d23ca7e
relates to:
Issue Description:
Swift currently cannot convert an array of types conforming to a protocol X to an array of [X]. It is possible to circumvent this by using `map`.
Example:
The example project is also available on GitHub: https://github.com/Ben-G/AppleBugProjects/blob/master/ProtocolArrayTypeConversion/ProtocolArrayTypeConversion/main.swift
The text was updated successfully, but these errors were encountered: