Smalltalk/X has both #min:max: and #clampBetween:and:
in its Magnitude.st.  Dolphin 7 has neither.

The definition of #clampBetween:and: in ST/X is

clampBetween: min and: max
    max < self ifTrue: [^max].
    self < min ifTrue: [^min].
    ^self

I've deleted the comment because it doesn't help with the question
"what is the CONTRACT for this method?"  In particular, you would
naturally expect from the name that
    (x clampBetween: y and: z) between: y and: z
Example:
    3 clampBetween: 2 and: 1  ==>  1
    1 between: 2 and: 1  ==>  false


On 22 April 2018 at 04:35, Hilaire <hila...@drgeo.eu> wrote:

> The #min:max: message is present in the Squeak/Pharo/Cuis familly but not
> in GNU Smalltalk for example. No idea about the other ones.
>
>
> Le 21/04/2018 à 00:12, Chris Cunningham a écrit :
>
>> A name like this would be clearer (although much more annoying):
>>
>> returnAtLeast: minValue butNoMoreThan: maxValue
>>     10 returnAtLeast: 12 butNoMoreThan: 48
>>
>>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>

Reply via email to