Bring Back Swift’s Old Half-closed Range Operator

Swift

If you’re one of the many (many) people who dislike the change Apple made to the half-closed range operator, then rejoice, because with this snippet of code you can bring it back:

[Edit: there’s a better version of this code at the end, see it now.]

And then you can use it just like before:

This really just shows the power of Swift, in that we can define a lot of how we want it to work ourselves.

Here’s an updated version which is more concise: