From: Artem Voroztsov Date: 2008-03-18T20:20:07+09:00 Subject: Questions on Enumerator#skip_first and Enumerable#first I asked in ruby-talk, but did not get answer. 1. What is the right way to write Enumerator#skip_first? I tried the following: [ruby-1.9]$ ./ruby -v ruby 1.9.0 (2008-03-18 revision 15793) [i686-linux] [ruby-1.9]$ cat test_skip.rb module Enumerable class Enumerator def skip_first(n=1) n.times {puts "Skiping #{self.next}" } self end end end p (1..5).each.skip_first(2).map{|i| i} [ruby-1.9]$ ./ruby test_skip.rb Skiping 1 Skiping 2 [1, 2, 3, 4, 5] But it did not work. Enumerator restarts in method map. It looks strange for me. 2. Is it good idea to have Enumerable#first? Now one has to write: enum.take(1).first Artem, Moscow Institute of Physics and Technology, Computer Science Department