1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* range.c (range_each, range_step): Return an enumerator if no

block is given.

* struct.c (rb_struct_each, rb_struct_each_pair): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2008-04-14 04:22:44 +00:00
parent 7d848354f8
commit 80361e2c47
4 changed files with 23 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Mon Apr 14 13:19:36 2008 Akinori MUSHA <knu@iDaemons.org>
* range.c (range_each, range_step): Return an enumerator if no
block is given.
* struct.c (rb_struct_each, rb_struct_each_pair): Ditto.
Mon Apr 14 13:07:59 2008 Akinori MUSHA <knu@iDaemons.org>
* string.c (rb_str_partition, rb_str_rpartition,
@ -6,11 +13,6 @@ Mon Apr 14 13:07:59 2008 Akinori MUSHA <knu@iDaemons.org>
backported from 1.9. These methods are $KCODE aware unlike
#index, #rindex and #include?.
Mon Apr 14 00:11:22 2008 Akinori MUSHA <knu@iDaemons.org>
* struct.c (rb_struct_each, rb_struct_each_pair): Return
an enumerator if no block is given.
Sun Apr 13 15:55:52 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* object.c (sym_to_proc): new method Symbol#to_proc; backported

10
NEWS
View file

@ -68,6 +68,11 @@ with all sufficient information, see the ChangeLog file.
* Process.exec implemented.
* Range#each
* Range#step
Return an enumerator if no block is given.
* Regexp.union accepts an array of patterns.
* String#partition
@ -83,6 +88,11 @@ with all sufficient information, see the ChangeLog file.
New exception class that causes Kernel#loop to stop iteration when
raised.
* Struct#each
* Struct#each_pair
Return an enumerator if no block is given.
* Symbol#to_proc implemented.
* enumerator

View file

@ -310,6 +310,8 @@ range_step(argc, argv, range)
VALUE b, e, step;
long unit;
RETURN_ENUMERATOR(range, argc, argv);
b = rb_ivar_get(range, id_beg);
e = rb_ivar_get(range, id_end);
if (rb_scan_args(argc, argv, "01", &step) == 0) {
@ -411,6 +413,8 @@ range_each(range)
{
VALUE beg, end;
RETURN_ENUMERATOR(range, 0, 0);
beg = rb_ivar_get(range, id_beg);
end = rb_ivar_get(range, id_end);

View file

@ -431,6 +431,7 @@ rb_struct_each(s)
{
long i;
RETURN_ENUMERATOR(s, 0, 0);
for (i=0; i<RSTRUCT(s)->len; i++) {
rb_yield(RSTRUCT(s)->ptr[i]);
}
@ -462,6 +463,7 @@ rb_struct_each_pair(s)
VALUE members;
long i;
RETURN_ENUMERATOR(s, 0, 0);
members = rb_struct_members(s);
for (i=0; i<RSTRUCT(s)->len; i++) {
rb_yield_values(2, rb_ary_entry(members, i), RSTRUCT(s)->ptr[i]);