зеркало из https://github.com/github/ruby.git
[DOC] Add doc for behavior when passing nil to Comparable#clamp(min, max)
This commit is contained in:
Родитель
3e64cf60b5
Коммит
55eb0d5c78
6
compar.c
6
compar.c
|
@ -187,6 +187,12 @@ cmp_between(VALUE x, VALUE min, VALUE max)
|
|||
* 'd'.clamp('a', 'f') #=> 'd'
|
||||
* 'z'.clamp('a', 'f') #=> 'f'
|
||||
*
|
||||
* If _min_ is +nil+, it is considered smaller than _obj_,
|
||||
* and if _max_ is +nil+, it is considered greater than _obj_.
|
||||
*
|
||||
* -20.clamp(0, nil) #=> 0
|
||||
* 523.clamp(nil, 100) #=> 100
|
||||
*
|
||||
* In <code>(range)</code> form, returns _range.begin_ if _obj_
|
||||
* <code><=></code> _range.begin_ is less than zero, _range.end_
|
||||
* if _obj_ <code><=></code> _range.end_ is greater than zero, and
|
||||
|
|
Загрузка…
Ссылка в новой задаче