> This is code with negation operator:
>       return !self.lanes[position.y][currentLaneRange].contains(.Gap)
> 
> As I sad before negation operation is hard to spot. Moreover at first it 
> looks like I’m trying to negate self for some reason.
> 
> This is code with “not” property:
>       return self.lanes[position.y][currentLaneRange].contains(.Gap).not

I do agree with you that `!` is sometimes hard to notice, but I think putting 
the "not" at the end is sort of burying the lede—"if the lane at position y's 
current lane range contains a gap…NOT!" I don't like making `not(_:)` a 
function, and I don't think we should introduce a freestanding keyword just for 
this, either.

One workaround is to write this instead:

        return !!!self.lanes[position.y][currentLaneRange].contains(.Gap)

Three nots is logically equivalent to one, but far more visible. Of course, 
then you have to worry about accidentally writing two or four, which would be 
the opposite.

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to