Skip to content

Instantly share code, notes, and snippets.

@leemorgan
Created August 16, 2015 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemorgan/3906cd9dcdbc14a1f9fa to your computer and use it in GitHub Desktop.
Save leemorgan/3906cd9dcdbc14a1f9fa to your computer and use it in GitHub Desktop.
Array extension where Element: Int
extension Array where Element: Int {
func foo() {
}
}
var anArray = [Int]()
anArray.foo() // '[Int]' does not have a member named 'foo'
@leemorgan
Copy link
Author

Ok. So this works...
It appears 'where' can only mark conformance to a protocol, and not that Element is of a certain type.

    extension Array where Element: IntegerType {
        func foo() {
        }
    }

    var anArray = [Int]()
    anArray.foo()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment