Method: Range#hash
- Defined in:
- range.c
permalink #hash ⇒ Integer
Returns the integer hash value for self
. Two range objects r0
and r1
have the same hash value if and only if r0.eql?(r1)
.
Related: Range#eql?, Object#hash.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'range.c', line 272
static VALUE
range_hash(VALUE range)
{
st_index_t hash = EXCL(range);
VALUE v;
hash = rb_hash_start(hash);
v = rb_hash(RANGE_BEG(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
v = rb_hash(RANGE_END(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
hash = rb_hash_uint(hash, EXCL(range) << 24);
hash = rb_hash_end(hash);
return ST2FIX(hash);
}
|