From: Martin DeMello Date: 2008-08-05T23:37:57+09:00 Subject: [ruby-core:18133] Re: New array methods cycle, choice, shuffle (plus bug in cycle) On Sun, Aug 3, 2008 at 9:37 AM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:18074] Re: New array methods cycle, choice, shuffle (plus bug in cycle)" > on Sat, 2 Aug 2008 06:43:56 +0900, David Flanagan writes: > > |If we agree that there is a use-case for adding #sample to the API, then > |I would also argue again for #sample! which removes the sampled elements > |from the array. There is no way to write #sample! based on #sample and > |I'd imagine that it would be usefule. > > I am against #sample!, because > > * #sample! is not the receiver modifying version of #sample. > * the intention can be expressed much better by applying #shuffle first, > then retrieving some elements from the randomized array. The second point looks wrong to me - I'd expect sample! to remove a random set of elements from the array without disturbing the ordering of the remaining elements. martin