From: Clifford Heath Date: 2008-02-07T10:30:03+09:00 Subject: Re: Array Practice Curt Sampson wrote: > On 2008-02-07 08:20 +0900 (Thu), Adam Akhtar wrote: >> [1,2,3,1,2,2,4,3,2,1] >> and then grouping them together and putting them in subarrays within an >> array like this >> [ [1,1,1], [2,2,2,2] , [3,3] ,[4] ] > > The Array#assoc method is your friend here. Really? Where's the array containing arrays come from? ------------------------------------------------------------ Array#assoc array.assoc(obj) -> an_array or nil ------------------------------------------------------------------------ Searches through an array whose elements are also arrays comparing obj with the first element of each contained array using obj.==. Returns the first contained array that matches (that is, the first associated array), or nil if no match is found. See also Array#rassoc. Clifford Heath.