Actions
Feature #19600
closedMethod `clamp?`
Status:
Closed
Assignee:
-
Target version:
-
Description
Currently, we have pairs of non-predicate and predicate methods like String#match
and String#match?
. Along this line, I propose the following. They are brain-friendly, and make programmers happier by saving them from terminology hell.
- Since by #19588,
Comparable#clamp
's behavior is made the same asRange#cover?
for range arguments, aliasRange#cover?
asRange#clamp?
. - Synchronize the specification of
Comparable#between?
withComparable#clamp
, i.e.,
a. AllowComparable#between?
to take a range argument, and
b. AllowComparable#between?
to takenil
as either or both of its arguments, or as either or both ends of its range argument. - Alias
Comparable#between?
asComparable#clamped?
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
Since the method clamp
makes a value covered by a range from an uncovered value, clamp?
doesn't feel same as cover?
or between?
, to me.
Extending Comparable#between?
sounds nice.
Updated by nobu (Nobuyoshi Nakada) almost 2 years ago
Updated by matz (Yukihiro Matsumoto) almost 2 years ago
- Status changed from Open to Closed
This issue includes multiple proposals, and the rationale is only explained 'brain-friendly', which may vary person to person.
Please make sure one issue contains only one proposal, with subjective rationale or real world use-cases.
For this particular case, I am not convinced by any of the proposals.
Matz.
Actions
Like0
Like0Like0Like0Like0Like0