String#concat: Try to convert when not string

This commit is contained in:
ksss
2017-05-21 10:30:27 +09:00
parent 78add72812
commit 98f9c33fe0
2 changed files with 18 additions and 7 deletions
+8 -1
View File
@@ -134,6 +134,8 @@ mrb_str_swapcase(mrb_state *mrb, mrb_value self)
return str;
}
static mrb_value mrb_fixnum_chr(mrb_state *mrb, mrb_value num);
/*
* call-seq:
* str << integer -> str
@@ -153,7 +155,12 @@ static mrb_value
mrb_str_concat2(mrb_state *mrb, mrb_value self)
{
mrb_value str;
mrb_get_args(mrb, "S", &str);
mrb_get_args(mrb, "o", &str);
if (mrb_fixnum_p(str))
str = mrb_fixnum_chr(mrb, str);
else
str = mrb_string_type(mrb, str);
mrb_str_concat(mrb, self, str);
return self;
}