[前][次][番号順一覧][スレッド一覧]

ruby-changes:14930

From: matz <ko1@a...>
Date: Wed, 3 Mar 2010 16:22:01 +0900 (JST)
Subject: [ruby-changes:14930] Ruby:r26801 (trunk): * lib/matrix.rb (Vector#each): make Vector enumerable.

matz	2010-03-03 16:19:21 +0900 (Wed, 03 Mar 2010)

  New Revision: 26801

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26801

  Log:
    * lib/matrix.rb (Vector#each): make Vector enumerable.  
      [ruby-core:28405]

  Modified files:
    trunk/ChangeLog
    trunk/lib/matrix.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26800)
+++ ChangeLog	(revision 26801)
@@ -1,3 +1,8 @@
+Wed Mar  3 16:14:24 2010  Yukihiro Matsumoto  <matz@r...>
+
+	* lib/matrix.rb (Vector#each): make Vector enumerable.  
+	  [ruby-core:28405]
+
 Wed Mar  3 14:28:23 2010  Yukihiro Matsumoto  <matz@r...>
 
 	* array.c (rb_ary_select_bang): select! removes all elements for
Index: lib/matrix.rb
===================================================================
--- lib/matrix.rb	(revision 26800)
+++ lib/matrix.rb	(revision 26801)
@@ -1081,6 +1081,7 @@
 #
 class Vector
   include ExceptionForMatrix
+  include Enumerable
 
   #INSTANCE CREATION
 
@@ -1141,6 +1142,16 @@
   #++
 
   #
+  # Iterate over the elements of this vector
+  #
+  def each
+    return to_enum(:each) unless block_given?
+    @elements.each do |i|
+      yield i
+    end
+  end
+
+  #
   # Iterate over the elements of this vector and +v+ in conjunction.
   #
   def each2(v) # :yield: e1, e2

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]