instance method
String#prepend
(*::string other_strings) -> self
prepend(*other_strings) → new_string
string.c
View on GitHub ↗
static VALUE
rb_str_prepend_multi(int argc, VALUE *argv, VALUE str)
{
str_modifiable(str);
if (argc == 1) {
rb_str_update(str, 0L, 0L, argv[0]);
}
else if (argc > 1) {
int i;
VALUE arg_str = rb_str_tmp_new(0);
rb_enc_copy(arg_str, str);
for (i = 0; i < argc; i++) {
rb_str_append(arg_str, argv[i]);
}
rb_str_update(str, 0L, 0L, arg_str);
}
return str;
}
Prefixes to self the concatenation of the given other_strings; returns self:
Example
'baz'.prepend('foo', 'bar') # => "foobarbaz"
Related: see Modifying.