instance method
String#replace
(::string other_string) -> self
replace(other_string) → self
string.c
View on GitHub ↗
VALUE
rb_str_replace(VALUE str, VALUE str2)
{
str_modifiable(str);
if (str == str2) return str;
StringValue(str2);
str_discard(str);
return str_replace(str, str2);
}
Replaces the contents of self with the contents of other_string; returns self:
Example
s = 'foo' # => "foo" s.replace('bar') # => "bar"
Related: see Modifying.