From: Jacob Fugal Date: 2005-12-22T07:22:18+09:00 Subject: Re: move to front of array On 12/21/05, Dan Diebolt wrote: > >That certainly would work (assuming that only one element matches the > condition), > > seems to work on multiple matches: Yeah, I realized that as I was working through my variation, but never made it back up to change the text. :) > I was uncertain about needing parenthesis before applying flatten but it makes perfect sense: > > array = (array.partition{ |el| el =~ /cool/i }).flatten! You don't need the bang here, however. Since Array#partition will always create nested arrays, you won't run into the flatten! returning nil bug, but it is still wasted effort to change a temporary array in place. Jacob Fugal