Forum: Ruby-dev Array#sample(n, replace=false)

Posted by yhara (Yutaka HARA) (Guest)
on 2012-10-25 11:04
(Received via mailing list)
Issue #3647 has been updated by yhara (Yutaka HARA).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #3647: Array#sample(n, replace=false)
https://bugs.ruby-lang.org/issues/3647#change-31522

Author: mrkn (Kenta Murata)
Status: Feedback
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: core
Target version: next minor


=begin
 Array#sample does not support sampling with replacement directly, so we 
must write codes like the following to obtain samples with replacement.

   samples_with_replacement = n.times.map { source.sample }

 If Array#sample has the argument for switching with/without 
replacement, we can write it as follow.

   samples_with_replacement = source.sample(n, true)

 The patch was attached.  Please consider to merge.
=end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.