summaryrefslogtreecommitdiff
path: root/doc/syntax/literals.rdoc
diff options
context:
space:
mode:
authorVictor Shepelev <zverok.offline@gmail.com>2021-12-19 18:09:52 +0200
committerGitHub <noreply@github.com>2021-12-20 01:09:52 +0900
commita0f10a973fb94a0ee73da7cab792128cdf601783 (patch)
treee025219312d597d04d0670951c13a867f2f98721 /doc/syntax/literals.rdoc
parent1dd10e189274546689c0b59f6a76849b2808f255 (diff)
[DOC] Add documentation for hash value omission syntax
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5244 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'doc/syntax/literals.rdoc')
-rw-r--r--doc/syntax/literals.rdoc8
1 files changed, 8 insertions, 0 deletions
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index 66e17fd503..32fe5110ce 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -356,6 +356,14 @@ is equal to
{ :"a 1" => 1, :"b 2" => 2 }
+Hash values can be omitted, meaning that value will be fetched from the context
+by the name of the key:
+
+ x = 100
+ y = 200
+ h = { x:, y: }
+ #=> {:x=>100, :y=>200}
+
See Hash for the methods you may use with a hash.
== \Range Literals