[前][次][番号順一覧][スレッド一覧]

ruby-changes:15272

From: marcandre <ko1@a...>
Date: Fri, 2 Apr 2010 03:03:01 +0900 (JST)
Subject: [ruby-changes:15272] Ruby:r27156 (trunk): * lib/matrix.rb: New method #empty?

marcandre	2010-04-02 03:02:27 +0900 (Fri, 02 Apr 2010)

  New Revision: 27156

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27156

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

  Modified files:
    trunk/lib/matrix.rb

Index: lib/matrix.rb
===================================================================
--- lib/matrix.rb	(revision 27155)
+++ lib/matrix.rb	(revision 27156)
@@ -387,6 +387,14 @@
   #++
 
   #
+  # 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?
@@ -910,7 +918,7 @@
   # 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 @@
   # Overrides Object#inspect
   #
   def inspect
-    if row_size == 0 || column_size == 0
+    if empty?
       "Matrix.empty(#{row_size}, #{column_size})"
     else
       "Matrix#{@rows.inspect}"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]