ruby-changes:16202
From: marcandre <ko1@a...>
Date: Sat, 5 Jun 2010 13:18:20 +0900 (JST)
Subject: [ruby-changes:16202] Ruby:r28167 (trunk): * lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning
marcandre 2010-06-05 13:18:08 +0900 (Sat, 05 Jun 2010) New Revision: 28167 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28167 Log: * lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning some empty matrices. Modified files: trunk/ChangeLog trunk/lib/matrix.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28166) +++ ChangeLog (revision 28167) @@ -1,3 +1,8 @@ +Sat Jun 5 13:13:30 2010 Marc-Andre Lafortune <ruby-core@m...> + + * lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning + some empty matrices. + Sat Jun 5 11:00:48 2010 Tanaka Akira <akr@f...> * error.c (rb_name_err_mesg_new): guard mesg, recv and method. Index: lib/matrix.rb =================================================================== --- lib/matrix.rb (revision 28166) +++ lib/matrix.rb (revision 28167) @@ -442,7 +442,7 @@ rows = @rows[from_row, size_row].collect{|row| row[from_col, size_col] } - new_matrix rows, column_size - from_col + new_matrix rows, [column_size - from_col, size_col].min end #-- @@ -493,12 +493,14 @@ # Returns +true+ if and only if the two matrices contain equal elements. # def ==(other) - return false unless Matrix === other + return false unless Matrix === other && + column_size == other.column_size # necessary for empty matrices rows == other.rows end def eql?(other) - return false unless Matrix === other + return false unless Matrix === other && + column_size == other.column_size # necessary for empty matrices rows.eql? other.rows end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/