Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added additional documentation examples for Array#sample #74

Closed
wants to merge 1 commit into from

3 participants

SeanMarcia Ayumu AIZAWA Matt Burke
SeanMarcia

a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
a.sample #=> [7]
a.sample(4) #=> [6, 4, 2, 5]

Ayumu AIZAWA
Collaborator

Merged by r34210. Thanks.

Ayumu AIZAWA ayumin closed this
Matt Burke

Shouldn't a.sample #=> 7 (not an array)?

SeanMarcia

fark... My first commit to ruby and I messed it up. :(
New pull request sent that fixes it... Sorry everyone.

Matt Burke

no worries. everyone messes up every once in a while.

i just happened to see it while passing through, and i was happy to learn (relearn?) that the #sample method exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 03, 2012
  1. SeanMarcia
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 1 array.c
5 array.c
View
@@ -3952,7 +3952,10 @@ rb_ary_shuffle(int argc, VALUE *argv, VALUE ary)
* contained duplicate elements. If the array is empty the first form returns
* <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]
*/
Something went wrong with that request. Please try again.