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

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@rakuten.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2018-07-27 17:28:41 +00:00
parent ecf4641b4c
commit efee3033b5

4
hash.c
View file

@ -1731,11 +1731,15 @@ rb_hash_replace(VALUE hash, VALUE hash2)
* 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