Issue #5584 has been updated by Masaki Matsushita.


Mon, 7 Nov 2011 22:53:21 Yusuke Endoh <mame tsg.ne.jp>:
>sample! ???????????????????大?????????????????????????????????????????????????????????????

?????????????????????pick???draw???????????????????????????????
???人??????pick??????????????????????

Tue, 8 Nov 2011 00:44:07 ???? ???? <miche mac.com>:
>Enumerator???使???????????????????????????????

Enumerator#next???????????????????????????Enumerable#take??????????????????????????????????

a = (1..10).to_a.shuffle.each
a.take(3) #=> [10, 2, 6]
a.take(3) #=> [10, 2, 6]
----------------------------------------
Feature #5584: Array#sample!
http://redmine.ruby-lang.org/issues/5584

Author: Masaki Matsushita
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0


=begin
?????????????????????????????????????????????????????????????Array#sample!??追????????????????????

????????????????????????????????????????????????????

 a = (1..5).to_a
 a.delete_at(rand(a.size)) #=> 3
 p a #=> [1, 2, 4, 5]
 
??????????????????????????????Array#sample!????????????

 a = (1..5).to_a
 a.sample! #=> 4
 p a #=> [1, 2, 3, 5]

??簡????????????????????

????????????????????????????????????????????????????????????????????????????????????????????????????????????????

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

????????????????????????????????????????????以??????Array#sample????????????????????????

 [].sample! #=> nil
 [].sample!(1) #=> []
 [1,2,3].sample!(random: rand) #=> 2

patch???添????????????
=end


-- 
http://redmine.ruby-lang.org