From e36ccef54916dc19ea3780acbfe5b110f985fa91 Mon Sep 17 00:00:00 2001 From: stomar Date: Thu, 2 Nov 2017 20:38:04 +0000 Subject: io.c: improve docs for the chomp option * io.c: [DOC] improve the description for the chomp option and add examples to IO.readlines and IO#readlines; other small fixes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/io.c b/io.c index ef0967eb73..6a9a273b41 100644 --- a/io.c +++ b/io.c @@ -3620,10 +3620,10 @@ static VALUE io_readlines(const struct getline_arg *arg, VALUE io); * ios.readlines(sep, limit [, getline_args]) -> array * * Reads all of the lines in ios, and returns them in - * anArray. Lines are separated by the optional sep. If + * an array. Lines are separated by the optional sep. If * sep is +nil+, the rest of the stream is returned * as a single record. - * If the first argument is an integer, or + * If the first argument is an integer, or an * optional second argument is given, the returning string would not be * longer than the given value in bytes. The stream must be opened for * reading or an IOError will be raised. @@ -3631,6 +3631,9 @@ static VALUE io_readlines(const struct getline_arg *arg, VALUE io); * f = File.new("testfile") * f.readlines[0] #=> "This is line one\n" * + * f = File.new("testfile", chomp: true) + * f.readlines[0] #=> "This is line one" + * * See IO.readlines for details about getline_args. */ @@ -10268,6 +10271,9 @@ io_s_readlines(struct getline_arg *arg) * a = IO.readlines("testfile") * a[0] #=> "This is line one\n" * + * b = IO.readlines("testfile", chomp: true) + * b[0] #=> "This is line one" + * * If the last argument is a hash, it's the keyword argument to open. * * === Options for getline @@ -10275,11 +10281,11 @@ io_s_readlines(struct getline_arg *arg) * The options hash accepts the following keys: * * :chomp:: - * Specifies the boolean. It will remove \n, \r, and \r\n - * from the end of each lines if it's true - * - * And see also IO.read for details about open_args. + * When the optional +chomp+ keyword argument has a true value, + * \n, \r, and \r\n + * will be removed from the end of each line. * + * See also IO.read for details about open_args. */ static VALUE -- cgit v1.2.3