[前][次][番号順一覧][スレッド一覧]

ruby-changes:48591

From: stomar <ko1@a...>
Date: Wed, 8 Nov 2017 05:17:16 +0900 (JST)
Subject: [ruby-changes:48591] stomar:r60713 (trunk): hash.c: improve docs for Hash#slice

stomar	2017-11-08 05:17:04 +0900 (Wed, 08 Nov 2017)

  New Revision: 60713

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60713

  Log:
    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.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 60712)
+++ hash.c	(revision 60713)
@@ -1329,12 +1329,11 @@ rb_hash_reject(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L1329
  *  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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]