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:
parent
fac245828b
commit
af6e31b344
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue