On 4 October 2017 at 13:41, Alex Blewitt <[email protected]> wrote:
>
> The difference between the & and && operators isn't to do with the
> implicit conversions; it's to do with whether both sides of the expression
> are evaluated or not.
>
> false && system('rm -rf')
>
> You really don't want to do that if both sides are executed ...
>
actually, thanks for bringing this up as it leads up to a question:
how in swift do i define my &&& operator (that i may need for whatever
reason, e.g. logging) that will short-circuit
the calculation of right hand side if the left hand side is false?
infix operator &&&: LogicalConjunctionPrecedence
func &&&(left: Bool, right: Bool) -> Bool {
return left && right
}
as written it doesn't short-circuit. is it possible at all in swift?
Mike
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution