[swift-evolution] Add clamp(value: Bound) -> Bound to ClosedInterval
dabrahams at apple.com
Wed Feb 17 19:10:32 CST 2016
on Wed Feb 17 2016, Kevin Ballard <swift-evolution at swift.org> wrote:
> I'd like to see ClosedInterval gain a new method
> /// Returns `value` clamped to `self`.
> func clamp(value: Bound) -> Bound
> This can't go on HalfOpenInterval (and therefore can't go on
> IntervalType) because a half-open interval doesn't have a known
> largest-contained-value (and in fact it can be empty), but it's
> perfectly reasonable for ClosedInterval to have this.
It's well-defined when the value is an Index (has discreet values). But
that whole protocol is probably not long for this world...
More information about the swift-evolution