From 7506fde3e911100ccca169eff3a5f4916e8ed1da Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 21 Mar 2018 16:02:26 +0000 Subject: Improve documentation for 'text '.split The documentation didn't mention trailing spaces and the example only demonstrated the case with leading spaces. [Fix GH-1845] From: Rodrigo Rosenfeld Rosas git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index ebac5e043d..0ab2012c89 100644 --- a/string.c +++ b/string.c @@ -7641,8 +7641,8 @@ split_string(VALUE result, VALUE str, long beg, long len, long empty_count) * * If pattern is a String, then its contents are used as * the delimiter when splitting str. If pattern is a single - * space, str is split on whitespace, with leading whitespace and runs - * of contiguous whitespace characters ignored. + * space, str is split on whitespace, with leading and trailing + * 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, @@ -7665,8 +7665,8 @@ split_string(VALUE result, VALUE str, long beg, long len, long empty_count) * When the input +str+ is empty an empty Array is returned as the string is * considered to have no fields to split. * - * " 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"] + * " now's the time ".split(' ') #=> ["now's", "the", "time"] * " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"] * "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"] * "hello".split(//) #=> ["h", "e", "l", "l", "o"] -- cgit v1.2.3