From: Sebastian Hungerecker Date: 2007-08-31T01:33:55+09:00 Subject: Re: Need help randomly selecting unique values from an array Paul wrote: > foo = [2, 7, 10, 14] # (or could equal a diff't set of 4 > numbers) > > Now for this task, I'm not interested in the first element at all. > I'd rather just leave it alone and not delete it though. So you use foo[1..-1]. That will create a new array not containing the first item and leave the original array untouched. > What I need to do is pick 1 to 3 elements randomly from the array. I > can't reuse the numbers. foo[1..-1].sort_by {rand}.first(n) where n is a number between 1 and 3. HTH, Sebastian -- NP: Novembers Doom - Dark World Burden Jabber: sepp2k@jabber.org ICQ: 205544826