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

ruby-changes:51867

From: tenderlove <ko1@a...>
Date: Sat, 28 Jul 2018 02:28:45 +0900 (JST)
Subject: [ruby-changes:51867] tenderlove:r64081 (trunk): Include Hash#size in the examples

tenderlove	2018-07-28 02:28:41 +0900 (Sat, 28 Jul 2018)

  New Revision: 64081

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64081

  Log:
    Include Hash#size in the examples
    
    Both methods Hash#length and Hash#size share the same source code in
    Ruby, but they also share the same documentation. Now when you look at
    the documentation of Hash#size you only see examples for Hash#length,
    which is confusing. This commit includes Hash#size in the examples and
    also remarks that both methods are equivalent to each other.
    
    Co-authored-by: Alberto Almagro <alberto.almagro@r...>

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 64080)
+++ hash.c	(revision 64081)
@@ -1731,11 +1731,15 @@ rb_hash_replace(VALUE hash, VALUE hash2) https://github.com/ruby/ruby/blob/trunk/hash.c#L1731
  *     hsh.size      ->  integer
  *
  *  Returns the number of key-value pairs in the hash.
+ *  <code>Hash#length</code> and <code>Hash#size</code> are both equivalent to
+ *  each other.
  *
  *     h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
  *     h.length        #=> 4
+ *     h.size          #=> 4
  *     h.delete("a")   #=> 200
  *     h.length        #=> 3
+ *     h.size          #=> 3
  */
 
 VALUE

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

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