summaryrefslogtreecommitdiff
path: root/hash.c
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 /hash.c
parent1dd10e189274546689c0b59f6a76849b2808f255 (diff)
downloadruby-a0f10a973fb94a0ee73da7cab792128cdf601783.tar.gz
[DOC] Add documentation for hash value omission syntax
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c8
1 files changed, 8 insertions, 0 deletions
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: