mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[DOC] Hash.[]
returns a hash with no default value/proc [ci skip]
This commit is contained in:
parent
f810c007cf
commit
a73f13c907
1 changed files with 10 additions and 4 deletions
14
hash.c
14
hash.c
|
@ -1814,21 +1814,27 @@ rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
|
|||
*
|
||||
* With no argument, returns a new empty \Hash.
|
||||
*
|
||||
* When the single given argument is a \Hash,
|
||||
* returns a new \Hash populated with the entries from the given \Hash.
|
||||
* When the single given argument is a \Hash, returns a new \Hash
|
||||
* populated with the entries from the given \Hash, excluding the
|
||||
* default value or proc.
|
||||
*
|
||||
* h = {foo: 0, bar: 1, baz: 2}
|
||||
* Hash[h] # => {:foo=>0, :bar=>1, :baz=>2}
|
||||
*
|
||||
* When the single given argument is an \Array of 2-element Arrays,
|
||||
* returns a new \Hash object wherein each 2-element array forms a key-value entry:
|
||||
* returns a new \Hash object wherein each 2-element array forms a
|
||||
* key-value entry:
|
||||
*
|
||||
* Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1}
|
||||
*
|
||||
* When the argument count is an even number;
|
||||
* returns a new \Hash object wherein each successive pair of arguments
|
||||
* has become a key-value entry:
|
||||
*
|
||||
* Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1}
|
||||
*
|
||||
* Raises an exception if the argument list does not conform to any of the above.
|
||||
* Raises an exception if the argument list does not conform to any
|
||||
* of the above.
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Reference in a new issue