mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[DOC] Tweaks for Hash#slice
This commit is contained in:
parent
86eff8565b
commit
1b2cc9c2b8
Notes:
git
2025-03-12 01:55:07 +00:00
Merged: https://github.com/ruby/ruby/pull/12907 Merged-By: peterzhu2118 <peter@peterzhu.ca>
1 changed files with 6 additions and 4 deletions
10
hash.c
10
hash.c
|
@ -2646,11 +2646,13 @@ rb_hash_reject(VALUE hash)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* slice(*keys) -> new_hash
|
* slice(*keys) -> new_hash
|
||||||
*
|
*
|
||||||
* Returns a new +Hash+ object containing the entries for the given +keys+:
|
* Returns a new hash containing the entries from +self+ for the given +keys+;
|
||||||
* h = {foo: 0, bar: 1, baz: 2}
|
* ignores any keys that are not found:
|
||||||
* h.slice(:baz, :foo) # => {baz: 2, foo: 0}
|
|
||||||
*
|
*
|
||||||
* Any given +keys+ that are not found are ignored.
|
* h = {foo: 0, bar: 1, baz: 2}
|
||||||
|
* h.slice(:baz, :foo, :nosuch) # => {baz: 2, foo: 0}
|
||||||
|
*
|
||||||
|
* Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue