Skip to content

Commit

Permalink
String#initialize to make a string empty; ref #3574
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 3, 2017
1 parent a14a930 commit d27a3d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,9 +1665,11 @@ mrb_str_init(mrb_state *mrb, mrb_value self)
{
mrb_value str2;

if (mrb_get_args(mrb, "|S", &str2) == 1) {
str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
if (mrb_get_args(mrb, "|S", &str2) == 0) {
struct RString *s = str_new(mrb, 0, 0);
str2 = mrb_obj_value(s);
}
str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
return self;
}

Expand Down

0 comments on commit d27a3d4

Please sign in to comment.