diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-24 18:46:15 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-24 18:46:15 +0000 |
commit | 3f9b0936aa846bdf6984019ca40bc629fe05d929 (patch) | |
tree | 59852ade00f43a1b6325bce662512c18ca596bcf /NEWS | |
parent | 7f0dd3a5a23d0009862e0f1213e536fff1a94727 (diff) | |
download | ruby-3f9b0936aa846bdf6984019ca40bc629fe05d929.tar.gz |
String#{lines,chars,codepoints,bytes} now return an array.
* string.c (rb_str_each_line, rb_str_lines): String#lines now
returns an array instead of an enumerator. Passing a block is
deprecated but still supported for backwards compatibility.
Based on the patch by yhara. [Feature #6670]
* string.c (rb_str_each_char, rb_str_chars): Ditto for
String#chars.
* string.c (rb_str_each_codepoint, rb_str_codepoints): Ditto for
String#codepoints.
* string.c (rb_str_each_byte, rb_str_bytes): Ditto for
String#bytes.
* NEWS: Add notes for the above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'NEWS')
-rw-r--r-- | NEWS | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -129,6 +129,11 @@ with all sufficient information, see the ChangeLog file. * String * added method: * added String#b returning a copied string whose encoding is ASCII-8BIT. + * change return value: + * String#lines now returns an array instead of an enumerator. + * String#chars now returns an array instead of an enumerator. + * String#codepoints now returns an array instead of an enumerator. + * String#bytes now returns an array instead of an enumerator. * Struct * added method: @@ -302,6 +307,18 @@ with all sufficient information, see the ChangeLog file. See above. + * String#lines + * String#chars + * String#codepoints + * String#bytes + + These methods no longer return an Enumerator, although passing a + block is still supported for backwards compatibility. + + Code like str.lines.with_index(1) { |line, lineno| ... } no longer + works because str.lines returns an array. Replace lines with + each_line in such cases. + * Signal.trap See above. |