Well, sometimes it might be important that you are dealing with an instance
variable, and in other cases, it's just clutter:
struct Triangle {
var a: Float
var b: Float
var c: Float
var isSquare: Bool {
return self.a * self.a + self.b * self.b == self.c * self.c
}
var isStillSquare: Bool {
return a * a + b * b == c * c
}
}
Imho the second variant is clearly better than the first, and it would be bad
to enforce self.
My personal rule of thumb for this is: Use the self prefix for things that
should change self, skip it for read-only access — but the exact "rules" are
quite arcane, and I think the compiler shouldn't have to deal with complicated
rules that still would fail to make everyone happy.
So, I think the current approach is the best we can do.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users