[macruby-changes] [1611] MacRuby/branches/experimental/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed May 27 13:27:22 PDT 2009
Revision: 1611
http://trac.macosforge.org/projects/ruby/changeset/1611
Author: pthomson at apple.com
Date: 2009-05-27 13:27:22 -0700 (Wed, 27 May 2009)
Log Message:
-----------
Added IO#foreach.
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-05-27 20:18:15 UTC (rev 1610)
+++ MacRuby/branches/experimental/io.c 2009-05-27 20:27:22 UTC (rev 1611)
@@ -619,8 +619,6 @@
static VALUE
rb_io_rewind(VALUE io, SEL sel)
{
- // minor inefficiency here in that i'm creating and then destroying
- // a Fixnum containing zero.
return rb_io_seek(io, INT2FIX(0), SEEK_SET);
}
@@ -3234,7 +3232,13 @@
static VALUE
rb_io_s_foreach(VALUE recv, SEL sel, int argc, VALUE *argv)
{
-rb_notimplement();
+ VALUE arr = rb_io_s_readlines(recv, sel, argc, argv);
+ int ii;
+ for (ii=0; ii<RARRAY_LEN(arr); ii++) {
+ VALUE at = RARRAY_AT(arr, ii);
+ rb_vm_yield(1, &at);
+ }
+ return Qnil;
}
/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090527/2a2b5f2c/attachment.html>
More information about the macruby-changes
mailing list