Issue #5584 has been updated by Hiro Asari.


?????>????堺?遵?冴????? random sampling ??????????????????????障?????с??紊?絨???激????? Enumerable#random_sampling(n) ????????????????????????????障?????
#sample! ???薈????с??#random_sampling ?????潔???????????違?????????綽泣??絨?ャ?????????後?????????????????<???????????????????障?????
----------------------------------------
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]

???激?若??????????御????????荀?膣???????????サ??c?????障??篋?篁ュ??????Array#sample??????????篏?????????障?????

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

patch???羞私???????障?????
=end


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