From a73f13c9070a5189947641638398cbffb8d012d8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 4 Jul 2021 14:56:23 +0900 Subject: [PATCH] [DOC] `Hash.[]` returns a hash with no default value/proc [ci skip] --- hash.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hash.c b/hash.c index 33b553d466..ec41bf13c7 100644 --- a/hash.c +++ b/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