From: Shashank Date Date: 2003-06-23T00:49:22+09:00 Subject: Re: reading text line "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> > > Even better.. you can use 'partition' instead > > file = __FILE__ > ok = true > res1, res2 = IO.readlines(file).partition { |obj| ok = !ok } > p res1, res2 Hmm.. did not know about partition. Thanks for pointing it out. Since Ruby is a language with class ;-) I came up with this more "classic" (generic) solution: #---------------------------------------------------------------- class Array def skip(n=0,from=0) raise "Cannot skip negative elements" if n < 0 0.step(self.length-1,n+1){|i| yield(self[i+from]) if self[i+from]} end end IO.readlines("junk.txt").skip(1){|line| puts line} #----------------------------------------------------------------