summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-07 20:17:04 (GMT)
committerstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-07 20:17:04 (GMT)
commit6f33cde636eb88e3e9f3c4f4d436137c52cd4cfb (patch)
treef9145b61a1442e53923e7349acc1f70e6d6e3f2b /hash.c
parent8b1c1c55a92a0879f9a99bb48ff7b4b280f2bce0 (diff)
hash.c: improve docs for Hash#slice
* hash.c: [DOC] clarify description for Hash#slice and remove a sentence that might suggest that the receiver is modified; improve example to also include a case where a hash with several elements is returned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/hash.c b/hash.c
index a3c576d..c8d1406 100644
--- a/hash.c
+++ b/hash.c
@@ -1329,12 +1329,11 @@ rb_hash_reject(VALUE hash)
* call-seq:
* hsh.slice(*keys) -> a_hash
*
- * Slices a hash to include only the given keys.
- * Returns a hash containing the given keys.
+ * Returns a hash containing only the given keys and their values.
*
- * h = { "a" => 100, "b" => 200, "c" => 300 }
- * h.slice("a") #=> {"a"=>100}
- * h.slice("c", "d") #=> {"c"=>300}
+ * h = { a: 100, b: 200, c: 300 }
+ * h.slice(:a) #=> {:a=>100}
+ * h.slice(:b, :c, :d) #=> {:b=>200, :c=>300}
*/
static VALUE