Project

General

Profile

Feature #12996 ยป range-eqq.patch

ksss (Yuki Kurihara), 12/02/2016 05:07 AM

View differences:

range.c
1119 1119
/*
1120 1120
 *  call-seq:
1121 1121
 *     rng === obj       ->  true or false
1122
 *
1123
 *  Returns <code>true</code> if +obj+ is an element of the range,
1124
 *  <code>false</code> otherwise.  Conveniently, <code>===</code> is the
1125
 *  comparison operator used by <code>case</code> statements.
1126
 *
1127
 *     case 79
1128
 *     when 1..50   then   print "low\n"
1129
 *     when 51..75  then   print "medium\n"
1130
 *     when 76..100 then   print "high\n"
1131
 *     end
1132
 *
1133
 *  <em>produces:</em>
1134
 *
1135
 *     high
1136
 */
1137

  
1138
static VALUE
1139
range_eqq(VALUE range, VALUE val)
1140
{
1141
    return rb_funcall(range, rb_intern("include?"), 1, val);
1142
}
1143

  
1144

  
1145
/*
1146
 *  call-seq:
1147 1122
 *     rng.member?(obj)  ->  true or false
1148 1123
 *     rng.include?(obj) ->  true or false
1149 1124
 *
......
1333 1308
    rb_define_method(rb_cRange, "initialize", range_initialize, -1);
1334 1309
    rb_define_method(rb_cRange, "initialize_copy", range_initialize_copy, 1);
1335 1310
    rb_define_method(rb_cRange, "==", range_eq, 1);
1336
    rb_define_method(rb_cRange, "===", range_eqq, 1);
1311
    rb_define_method(rb_cRange, "===", range_include, 1);
1337 1312
    rb_define_method(rb_cRange, "eql?", range_eql, 1);
1338 1313
    rb_define_method(rb_cRange, "hash", range_hash, 0);
1339 1314
    rb_define_method(rb_cRange, "each", range_each, 0);