Skip to content

Commit ba148e7

Browse files
[DOC] Tweaks for Hash#[]
1 parent 9be6e42 commit ba148e7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

hash.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,16 +2090,19 @@ rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
20902090

20912091
/*
20922092
* call-seq:
2093-
* hash[key] -> value
2093+
* self[key] -> object
20942094
*
2095-
* Returns the value associated with the given +key+, if found:
2096-
* h = {foo: 0, bar: 1, baz: 2}
2097-
* h[:foo] # => 0
2095+
* Searches for a hash key equivalent to the given +key+;
2096+
* see {Hash Key Equivalence}[rdoc-ref:Hash@Hash+Key+Equivalence].
20982097
*
2099-
* If +key+ is not found, returns a default value
2100-
* (see {Hash Default}[rdoc-ref:Hash@Hash+Default]):
2101-
* h = {foo: 0, bar: 1, baz: 2}
2102-
* h[:nosuch] # => nil
2098+
* If the key is found, returns its value:
2099+
*
2100+
* {foo: 0, bar: 1, baz: 2}
2101+
* h[:bar] # => 1
2102+
*
2103+
* Otherwise, returns a default value (see {Hash Default}[rdoc-ref:Hash@Hash+Default]).
2104+
*
2105+
* Related: #[]=; see also {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
21032106
*/
21042107

21052108
VALUE

0 commit comments

Comments
 (0)