summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/string.c b/string.c
index eb7b3474470..08aa302aaf0 100644
--- a/string.c
+++ b/string.c
@@ -2557,7 +2557,11 @@ rb_str_split_m(argc, argv, str)
if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) {
lim = NUM2INT(limit);
if (lim <= 0) limit = Qnil;
- else if (lim == 1) return rb_ary_new3(1, str);
+ else if (lim == 1) {
+ if (RSTRING(str)->len == 0)
+ return rb_ary_new2(0);
+ return rb_ary_new3(1, str);
+ }
i = 1;
}