Ray_Fix
(Ray Fix)
1
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
Ben_Cohen
(Ben Cohen)
2
Dunno about good form, but the std lib universally employs the _-less variant if that helps:
The _ certainly seem like clutter to me.
Same for subscripts, which have similar behavior.
···
On Jan 24, 2017, at 10:14 AM, Ray Fix via swift-users <swift-users@swift.org> wrote:
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
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users