> On 15 Mar 2017, at 19:40, Nate Cook via swift-evolution
> <[email protected]> wrote:
>
> Hi Nick,
>
> I think this might have come up in an earlier thread, but clamped(to:) with a
> half-open range argument brings up the question of how to clamp to an empty
> range. As proposed, the implementation of this method would result in an
> error when passed an empty range:
>
> foo.clamped(to: 0..<0)
> // fatal error: Can't form Range with upperBound < lowerBound
>
> Is that the desired behavior? Providing documentation for both new methods
> would help make it clear what the expected functionality is.
I'd say that's the correct behaviour; it makes no sense to call a clamp method
without anything to actually clamp to; an empty range contains nothing, so not
only can't include the value you're testing against, but also has no bounds to
clamp to instead.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution