From: Robert Klemme Date: 2006-06-23T17:45:55+09:00 Subject: Re: Randomly select an element from an array 2006/6/22, Chris Hulan : > David Solis wrote: > > I have an array: > > > > [1,2,3,4,5] > > > > How do I randomly select an element from the array? > > Array now has built-in random sorting so you could > > [1,2,3,4,5].sort_by{rand}.last While this certainly works it's extremely inefficient. robert -- Have a look: http://www.flickr.com/photos/fussel-foto/