1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_sample): add examples for Array#sample.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ayumin 2012-01-04 09:03:20 +00:00
parent 460528289a
commit 6992be63d8
2 changed files with 9 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Wed Jan 04 17:55:53 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
* array.c (rb_ary_sample): add example for Array#sample
based on patch from https://github.com/ruby/ruby/pull/74
Wed Jan 4 14:24:33 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_nth_len): count ascii-only run at the end. this

View file

@ -3953,6 +3953,10 @@ rb_ary_shuffle(int argc, VALUE *argv, VALUE ary)
* <code>nil</code> and the second form returns an empty array.
*
* If +rng+ is given, it will be used as the random number generator.
*
* a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
* a.sample #=> [7]
* a.sample(4) #=> [6, 4, 2, 5]
*/