Feature #12996 » range-eqq.patch
range.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* rng === obj -> true or false
|
||
*
|
||
* Returns <code>true</code> if +obj+ is an element of the range,
|
||
* <code>false</code> otherwise. Conveniently, <code>===</code> is the
|
||
* comparison operator used by <code>case</code> statements.
|
||
*
|
||
* case 79
|
||
* when 1..50 then print "low\n"
|
||
* when 51..75 then print "medium\n"
|
||
* when 76..100 then print "high\n"
|
||
* end
|
||
*
|
||
* <em>produces:</em>
|
||
*
|
||
* high
|
||
*/
|
||
static VALUE
|
||
range_eqq(VALUE range, VALUE val)
|
||
{
|
||
return rb_funcall(range, rb_intern("include?"), 1, val);
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* rng.member?(obj) -> true or false
|
||
* rng.include?(obj) -> true or false
|
||
*
|
||
... | ... | |
rb_define_method(rb_cRange, "initialize", range_initialize, -1);
|
||
rb_define_method(rb_cRange, "initialize_copy", range_initialize_copy, 1);
|
||
rb_define_method(rb_cRange, "==", range_eq, 1);
|
||
rb_define_method(rb_cRange, "===", range_eqq, 1);
|
||
rb_define_method(rb_cRange, "===", range_include, 1);
|
||
rb_define_method(rb_cRange, "eql?", range_eql, 1);
|
||
rb_define_method(rb_cRange, "hash", range_hash, 0);
|
||
rb_define_method(rb_cRange, "each", range_each, 0);
|