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] */