mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_invert): [DOC] more examples.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1ee9cad027
commit
f061d40326
2 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat Feb 13 21:44:58 2016 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* hash.c (rb_hash_invert): [DOC] more examples.
|
||||
|
||||
Sat Feb 13 17:30:49 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/uri/generic.rb (URI::Generic#find_proxy): support CIDR in
|
||||
|
|
16
hash.c
16
hash.c
|
@ -2217,6 +2217,22 @@ rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
|
|||
* h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
|
||||
* h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"}
|
||||
*
|
||||
* If there is no key with the same value, Hash#invert is involutive.
|
||||
*
|
||||
* h = { a: 1, b: 3, c: 4 }
|
||||
* h.invert.invert == h #=> true
|
||||
*
|
||||
* The condition, no key with the same value, can be tested by comparing
|
||||
* the size of inverted hash.
|
||||
*
|
||||
* # no key with the same value
|
||||
* h = { a: 1, b: 3, c: 4 }
|
||||
* h.size == h.invert.size #=> true
|
||||
*
|
||||
* # two (or more) keys has the same value
|
||||
* h = { a: 1, b: 3, c: 1 }
|
||||
* h.size == h.invert.size #=> false
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Reference in a new issue