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

ruby-changes:13666

From: marcandre <ko1@a...>
Date: Sat, 24 Oct 2009 15:05:06 +0900 (JST)
Subject: [ruby-changes:13666] Ruby:r25451 (trunk): * lib/matrix (column): handle negative arguments. cf

marcandre	2009-10-24 15:04:56 +0900 (Sat, 24 Oct 2009)

  New Revision: 25451

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

  Log:
    * lib/matrix (column): handle negative arguments. cf [ruby-core:23598]

  Modified files:
    trunk/lib/matrix.rb

Index: lib/matrix.rb
===================================================================
--- lib/matrix.rb	(revision 25450)
+++ lib/matrix.rb	(revision 25451)
@@ -309,13 +309,13 @@
   #
   def column(j) # :yield: e
     if block_given?
-      return self if j >= column_size
+      return self if j >= column_size || j < -column_size
       row_size.times do |i|
         yield @rows[i][j]
       end
       self
     else
-      return nil if j >= column_size
+      return nil if j >= column_size || j < -column_size
       col = (0 ... row_size).collect {|i|
         @rows[i][j]
       }

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

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