Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
MatchData#hash
() -> ::Integer
hash → integer
re.c
View on GitHub ↗
static VALUE
match_hash(VALUE match)
{
st_index_t hashval;
match_check(match);
hashval = rb_hash_start(rb_str_hash(RMATCH(match)->str));
hashval = rb_hash_uint(hashval, reg_hash(match_regexp(match)));
int num_regs = RMATCH_NREGS(match);
hashval = rb_hash_uint(hashval, num_regs);
hashval = rb_hash_uint(hashval, rb_memhash(RMATCH_BEG_PTR(match), num_regs * sizeof(OnigPosition)));
hashval = rb_hash_uint(hashval, rb_memhash(RMATCH_END_PTR(match), num_regs * sizeof(OnigPosition)));
hashval = rb_hash_end(hashval);
return ST2FIX(hashval);
}
Returns the integer hash value for self, based on the target string, regexp, match, and captures.
See also Object#hash.