Actions
Feature #2265
closedMatrix#empty? [patch]
Description
=begin
Now that the Matrix library handles well empty matrices, how about a new instance method #empty?
diff --git a/lib/matrix.rb b/lib/matrix.rb
index b577ef3..45ef25e 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -386,6 +386,14 @@ class Matrix
#++
#
-
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.¶
def regular?
@@ -924,7 +932,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|
@@ -939,7 +947,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}"
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Assignee changed from keiju (Keiju Ishitsuka) to marcandre (Marc-Andre Lafortune)
- Target version set to 1.9.2
=begin
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r27156.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Actions
Like0
Like0Like0