concat(p1)
public
Append—Concatenates the given object to str. If the object
is a Fixnum between 0 and 255, it is
converted to a character before concatenation.
a = "hello "
a << "world"
a.concat(33)
Show source
/*
* call-seq:
* str << fixnum => str
* str.concat(fixnum) => str
* str << obj => str
* str.concat(obj) => str
*
* Append---Concatenates the given object to <i>str</i>. If the object is a
* <code>Fixnum</code> between 0 and 255, it is converted to a character before
* concatenation.
*
* a = "hello "
* a << "world" #=> "hello world"
* a.concat(33) #=> "hello world!"
*/
VALUE
rb_str_concat(str1, str2)
VALUE str1, str2;
{
if (FIXNUM_P(str2)) {
int i = FIX2INT(str2);
if (0 <= i && i <= 0xff) { /* byte */
char c = i;
return rb_str_cat(str1, &c, 1);
}
}
str1 = rb_str_append(str1, str2);
return str1;
}