Method: String#initialize_copy

Defined in:
string.c

#replace(other_str) ⇒ String

Replaces the contents of str with the corresponding values in other_str.

s = "hello"         #=> "hello"
s.replace "world"   #=> "world"

Returns:

[View source]

5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
# File 'string.c', line 5589

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);
}