For example
----------------
module Enumerable
class Enumerator
def skip_first(n=1)
n.times {puts "Skiping #{self.next}"}
self
end
end
end
puts [1,2,3,4].each.skip_first(2).map{|i| i}
----------------
Outputs
Skiping 1
Skiping 2
1
2
3
4
(ruby 1.9.0 (2007-12-25 revision 14709) [i386-mswin32])
So it does not skips in fact. Enumerator restarts inside method map.
It looks strange for me.
Can anyone help me to write 'skip_first' method that works?
Artem