[swift-users] Element vs. Iterator.Element

Toni Suter tonisuter at me.com
Mon Oct 31 07:28:32 CDT 2016


Hi,

This extension on Array works as expected:

extension Array where Element: CustomStringConvertible {
    func f(_ x: Element) -> String {
        return x.description
    }
}

But when I use Iterator.Element instead, I get an error message (error: value of type 'Element' has no member 'description'):

extension Array where Iterator.Element: CustomStringConvertible {
    func f(_ x: Iterator.Element) -> String {
        return x.description
    }
}

I assume this is a type checker bug, but before I report it, I wanted to make sure that that’s really the case. Or is there a difference between Element and
Iterator.Element?

Thanks and best regards,
Toni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161031/0e9f6964/attachment.html>


More information about the swift-users mailing list