Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
String#tr_s!
(::String::selector source, ::string replacement) -> self?
tr_s!(selector, replacements) → self or nil
string.c
View on GitHub ↗
static VALUE
rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
{
return tr_trans(str, src, repl, 1);
}
Like String#tr_s, except:
-
Modifies
selfin place (not a copy ofself). -
Returns
selfif any changes were made,nilotherwise.
Related: Modifying.