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

* lib/matrix.rb: New method #empty? [ruby-core:26284]

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

View file

@ -386,6 +386,14 @@ class Matrix
# TESTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
#
# Returns +true+ if this is an empty matrix, i.e. if the number of rows
# or the number of columns is 0.
#
def empty?
column_size == 0 || row_size == 0
end
#
# Returns +true+ if this is a regular matrix.
#
@ -910,7 +918,7 @@ class Matrix
# Overrides Object#to_s
#
def to_s
if row_size == 0 || column_size == 0
if empty?
"Matrix.empty(#{row_size}, #{column_size})"
else
"Matrix[" + @rows.collect{|row|
@ -923,7 +931,7 @@ class Matrix
# Overrides Object#inspect
#
def inspect
if row_size == 0 || column_size == 0
if empty?
"Matrix.empty(#{row_size}, #{column_size})"
else
"Matrix#{@rows.inspect}"