[swift-evolution] divisible-by operator
Félix Cloutier
felixcca at yahoo.ca
Thu Apr 7 01:07:50 CDT 2016
This is the kind of thing that I'd let live in a library and consider importing into the standard if a lot of people use it.
Félix
> Le 6 avr. 2016 à 09:13:41, Milos Rankovic via swift-evolution <swift-evolution at swift.org> a écrit :
>
> Checking for divisibility is very common:
>
> 21 % 3 == 0 // true
>
> In fact, this is such a common use of the `%` operator that the `== 0` side of the expression seems distracting in this use case. For quite a while now, I’ve been using a custom operator for this, which is steadily growing on me:
>
> 21 %== 3 // true
>
> … which also allows me to overload it for sequences:
>
> 21 %== [7, 3] // true
>
> (If I’m inadvertently misusing this mailing list to share such a minor idea, please tell me off so that I can learn not to do it again!)
>
> milos
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160406/e8e98d99/attachment.html>
More information about the swift-evolution
mailing list