From a0f10a973fb94a0ee73da7cab792128cdf601783 Mon Sep 17 00:00:00 2001 From: Victor Shepelev Date: Sun, 19 Dec 2021 18:09:52 +0200 Subject: [DOC] Add documentation for hash value omission syntax --- hash.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 1155a5756b..07ec93d784 100644 --- a/hash.c +++ b/hash.c @@ -6701,6 +6701,14 @@ static const rb_data_type_t env_data_type = { * # Raises SyntaxError (syntax error, unexpected ':', expecting =>): * h = {0: 'zero'} * + * Hash value can be omitted, meaning that value will be fetched from the context + * by the name of the key: + * + * x = 0 + * y = 100 + * h = {x:, y:} + * h # => {:x=>0, :y=>100} + * * === Common Uses * * You can use a \Hash to give names to objects: -- cgit v1.2.1