From 6992be63d89406222e1857ed9b8fa9a7e2c1a1c4 Mon Sep 17 00:00:00 2001 From: ayumin Date: Wed, 4 Jan 2012 09:03:20 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ array.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 84e3283712..7f974e4828 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jan 04 17:55:53 2012 Ayumu AIZAWA + + * 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 * string.c (str_nth_len): count ascii-only run at the end. this diff --git a/array.c b/array.c index 01cabc87b9..c0ebf66442 100644 --- a/array.c +++ b/array.c @@ -3953,6 +3953,10 @@ rb_ary_shuffle(int argc, VALUE *argv, VALUE ary) * nil 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] */