1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/matrix.rb (empty): Reject negative sizes

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2010-04-01 18:03:15 +00:00
parent fac245828b
commit af6e31b344

View file

@ -241,7 +241,8 @@ class Matrix
# => Matrix[[0, 0, 0], [0, 0, 0]]
#
def Matrix.empty(row_size = 0, column_size = 0)
Matrix.Raise ErrDimensionMismatch if column_size != 0 && row_size != 0
Matrix.Raise ArgumentError, "One size must be 0" if column_size != 0 && row_size != 0
Matrix.Raise ArgumentError, "Negative size" if column_size < 0 || row_size < 0
new([[]]*row_size, column_size)
end