On Wed, Nov 14, 2007 at 09:23:04PM +0900, Trans wrote: > On Nov 13, 10:51 pm, Trans <transf... / gmail.com> wrote: > > > However, a few times I've wanted a nicer way to split the array at an > > index. Something like: > > > > a.each_with_index do |el, i| > > pre, post = *a.crack(i) > > ... > > end > > Actually, can anyone recommend a better name than #crack? --or a way > to already do this? Maybe Array#partition_at to match Enumarable#partition ? class Array def partition_at(i) [ self[0..i], self[(i+1)..length] ] end end