diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-05 04:18:08 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-05 04:18:08 +0000 |
commit | 159fd9ee6cd7583bc78d8d092b3f4ba5cded5508 (patch) | |
tree | a255c7c766fd56945ebaf425ec4a28c7a0997ca1 /lib/matrix.rb | |
parent | 87c1da091cb9e9fdce5059dc2f27b89fbc705dc0 (diff) | |
download | ruby-159fd9ee6cd7583bc78d8d092b3f4ba5cded5508.tar.gz |
* lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning
some empty matrices.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/matrix.rb')
-rw-r--r-- | lib/matrix.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb index 79c4c7b1b3..8e6b08c3c6 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -442,7 +442,7 @@ class Matrix 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 @@ class Matrix # 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 |