From 799ad0e1c728190327c62290dd668bf34b321c4b Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sun, 27 Oct 2019 19:14:12 +0900 Subject: Refine `String#split` document --- src/string.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index e5c3a3843..ebcabad38 100644 --- a/src/string.c +++ b/src/string.c @@ -2108,23 +2108,18 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str) /* * call-seq: - * str.split(pattern="\n", [limit]) => anArray + * str.split(separator=nil, [limit]) => anArray * * Divides str into substrings based on a delimiter, returning an array * of these substrings. * - * If pattern is a String, then its contents are used as - * the delimiter when splitting str. If pattern is a single + * If separator is a String, then its contents are used as + * the delimiter when splitting str. If separator is a single * space, str is split on whitespace, with leading whitespace and runs * of contiguous whitespace characters ignored. * - * If pattern is a Regexp, str is divided where the - * pattern matches. Whenever the pattern matches a zero-length string, - * str is split into individual characters. - * - * If pattern is omitted, the value of $; is used. If - * $; is nil (which is the default), str is - * split on whitespace as if ' ' were specified. + * If separator is omitted or nil (which is the default), + * str is split on whitespace as if ' ' were specified. * * If the limit parameter is omitted, trailing null fields are * suppressed. If limit is a positive number, at most that number of @@ -2135,9 +2130,6 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str) * * " now's the time".split #=> ["now's", "the", "time"] * " now's the time".split(' ') #=> ["now's", "the", "time"] - * " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"] - * "hello".split(//) #=> ["h", "e", "l", "l", "o"] - * "hello".split(//, 3) #=> ["h", "e", "llo"] * * "mellow yellow".split("ello") #=> ["m", "w y", "w"] * "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"] @@ -2150,7 +2142,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) { mrb_int argc; mrb_value spat = mrb_nil_value(); - enum {awk, string, regexp} split_type = string; + enum {awk, string} split_type = string; mrb_int i = 0; mrb_int beg; mrb_int end; -- cgit v1.2.3