Shyouhei Urabe wrote: > Martin Dürst wrote: > ... Thanks, but I don't think I have access to editing this page. Or at least I can't find the button for it...nerdinand (Ferdinand Niedermann)
Where do we go from here? Is my patch acceptable? If no, what should I change? If yes, what's the process for getting it merged?nerdinand (Ferdinand Niedermann)
Benoit Daloze wrote: > Good luck explaining the precise semantics of clamp on String though. IMO it's not that hard to grasp: call-seq: obj.clamp(min, max) -> obj Returns min if obj <=> min is less than zero,...nerdinand (Ferdinand Niedermann)
D.E. Akers wrote: > Ferdinand Niedermann wrote: > ... That doesn't really change anything, but I updated the pull request. I added some more tests to prove that it doesn't raise given equal `min` and `max`.nerdinand (Ferdinand Niedermann)
> That `min > max` should raise an `ArgumentError` seems the only logical conclusion. I agree. I'll send another pull request including that. nerdinand (Ferdinand Niedermann)
I think there is even another option: Swapping the min and max values if they are passed in the wrong order. This is obviously a question of the principle of least surprise. If you compare `#clamp` to `#between?`, it makes sense to ac...nerdinand (Ferdinand Niedermann)
I tried the basic implementation (adaption of `#between?`). What should we do about cases like these? ``` irb(main):001:0> 1.clamp(2, 1) => 2 irb(main):002:0> 2.clamp(2, 1) => 1 ``` With `#between?` these make more sense, becaus...nerdinand (Ferdinand Niedermann)