Splendid !

-- shanko

"Brian Candler" <B.Candler / pobox.com> wrote in message
> A better, more generic solution would not use a[b] to index array
elements.
> If you limit yourself to using only 'each' then it would be compatible
with
> all classes which mix in Enumerable. Something like this:
>
> module Enumerable
>   def each_skip(n=0, from=0)
>     skip = from
>     each do |item|
>       if skip > 0
>         skip -= 1
>         next
>       end
>       yield item
>       skip = n
>     end
>   end
> end
>
> Now, you can use this directly on the IO object - you don't even have to
> read the lines into an array first (although it works on arrays as well).
If
> you have a file with a million lines then that makes quite a difference
:-)
>
> File.open("junk.txt").each_skip(1) {|line| puts line}