[swift-users] operators and external parameters

Ray Fix rayfix at gmail.com
Tue Jan 24 12:14:57 CST 2017


When defining an operator such as == you can implicitly specify external parameters:

struct Path: Equatable {
    var value: String

    static func ==(lhs: Path, rhs: Path) -> Bool {
        return lhs.value == rhs.value
    }
}

Is this considered okay, or is it bad form and it should really be defined:


struct Path: Equatable {
    var value: String

    static func ==(_ lhs: Path, _ rhs: Path) -> Bool {
        return lhs.value == rhs.value
    }
}

Both seem to work fine in practice… 🤔  

Thank you!
Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170124/848e2132/attachment.html>


More information about the swift-users mailing list