From efee3033b5ab03b4d4562c678e7a2feac8a110a9 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 27 Jul 2018 17:28:41 +0000 Subject: [PATCH] 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hash.c b/hash.c index 48fbe1f37c..c457923ddf 100644 --- a/hash.c +++ b/hash.c @@ -1731,11 +1731,15 @@ rb_hash_replace(VALUE hash, VALUE hash2) * hsh.size -> integer * * Returns the number of key-value pairs in the hash. + * Hash#length and Hash#size 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