diff options
author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2022-03-18 17:17:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 17:17:00 -0500 |
commit | d52f41b765b5992ee562cda6bd32fdd8f54b0091 (patch) | |
tree | 027933fa886c64d9efc6006cc9f3221d0390a3d5 /string.c | |
parent | 97426e15d721119738a548ecfa7232b1d027cd34 (diff) | |
download | ruby-d52f41b765b5992ee562cda6bd32fdd8f54b0091.tar.gz |
[DOC] Enhanced RDoc for String (#5675)
Treats:
#split
#each_line
#lines
#each_byte
#bytes
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 93 |
1 files changed, 7 insertions, 86 deletions
@@ -8652,9 +8652,7 @@ literal_split_pattern(VALUE spat, split_type_t default_type) return default_type; } -/* - * String#split is documented at doc/string.rdoc. - */ +// String#split is documented at doc/string.rdoc. static VALUE rb_str_split_m(int argc, VALUE *argv, VALUE str) @@ -9065,52 +9063,7 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary) return orig; } -/* - * call-seq: - * str.each_line(separator=$/, chomp: false) {|substr| block } -> str - * str.each_line(separator=$/, chomp: false) -> an_enumerator - * - * Splits <i>str</i> using the supplied parameter as the record - * separator (<code>$/</code> by default), passing each substring in - * turn to the supplied block. If a zero-length record separator is - * supplied, the string is split into paragraphs delimited by - * multiple successive newlines. - * - * If +chomp+ is +true+, +separator+ will be removed from the end of each - * line. - * - * If no block is given, an enumerator is returned instead. - * - * "hello\nworld".each_line {|s| p s} - * # prints: - * # "hello\n" - * # "world" - * - * "hello\nworld".each_line('l') {|s| p s} - * # prints: - * # "hel" - * # "l" - * # "o\nworl" - * # "d" - * - * "hello\n\n\nworld".each_line('') {|s| p s} - * # prints - * # "hello\n\n" - * # "world" - * - * "hello\nworld".each_line(chomp: true) {|s| p s} - * # prints: - * # "hello" - * # "world" - * - * "hello\nworld".each_line('l', chomp: true) {|s| p s} - * # prints: - * # "he" - * # "" - * # "o\nwor" - * # "d" - * - */ +// String#each_line is documented at doc/string.rdoc. static VALUE rb_str_each_line(int argc, VALUE *argv, VALUE str) @@ -9121,21 +9074,11 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str) /* * call-seq: - * str.lines(separator=$/, chomp: false) -> an_array - * - * Returns an array of lines in <i>str</i> split using the supplied - * record separator (<code>$/</code> by default). This is a - * shorthand for <code>str.each_line(separator, getline_args).to_a</code>. + * lines(Line_sep = $/, chomp: false) -> array_of_strings * - * If +chomp+ is +true+, +separator+ will be removed from the end of each - * line. + * Forms substrings ("lines") of +self+ according to the given arguments + * (see String#each_line for details); returns the lines in an array. * - * "hello\nworld\n".lines #=> ["hello\n", "world\n"] - * "hello world".lines(' ') #=> ["hello ", " ", "world"] - * "hello\nworld\n".lines(chomp: true) #=> ["hello", "world"] - * - * If a block is given, which is a deprecated form, works the same as - * <code>each_line</code>. */ static VALUE @@ -9165,20 +9108,7 @@ rb_str_enumerate_bytes(VALUE str, VALUE ary) return str; } -/* - * call-seq: - * str.each_byte {|integer| block } -> str - * str.each_byte -> an_enumerator - * - * Passes each byte in <i>str</i> to the given block, or returns an - * enumerator if no block is given. - * - * "hello".each_byte {|c| print c, ' ' } - * - * <em>produces:</em> - * - * 104 101 108 108 111 - */ +// String#each_byte is documented in doc/string.rdoc. static VALUE rb_str_each_byte(VALUE str) @@ -9187,16 +9117,7 @@ rb_str_each_byte(VALUE str) return rb_str_enumerate_bytes(str, 0); } -/* - * call-seq: - * str.bytes -> an_array - * - * Returns an array of bytes in <i>str</i>. This is a shorthand for - * <code>str.each_byte.to_a</code>. - * - * If a block is given, which is a deprecated form, works the same as - * <code>each_byte</code>. - */ +// String#bytes is documented in doc/string.rdoc. static VALUE rb_str_bytes(VALUE str) |