Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
String#tr!
(::String::selector source, ::string replacement) -> self?
tr!(selector, replacements) → self or nil
tr!(pairs) → self or nil
string.c
View on GitHub ↗
static VALUE
rb_str_tr_bang(int argc, VALUE *argv, VALUE str)
{
rb_check_arity(argc, 1, 2);
if (argc == 1) {
VALUE pairs = argv[0];
return tr_trans_pairs(str, pairs);
}
VALUE src = argv[0], repl = argv[1];
return tr_trans(str, src, repl, 0);
}