diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 4 |
2 files changed, 9 insertions, 0 deletions
@@ -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 @@ -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] */ |