From: mortee Date: 2007-10-26T13:31:11+09:00 Subject: Re: Skip the first invocation e.g. skip_first { foo } Pe�a wrote: > From: news [mailto:news@ger.gmane.org] On Behalf Of mortee > # def skip_first(_skip_count = 1) > # _iteration = 0 > # lambda do |x| > # yield x if _iteration >= _skip_count > # _iteration += 1 > # end > # end > # > # # you can then pass the lambda returned by skip_first to any iterator, > # # using the & notation > # > # 5.times &skip_first {|a| puts a} > # 1 > # 2 > # 3 > # 4 > > now that is cool :) > kind regards -botp Thx (: In the meantime I just realized that the binding of the block which does the real work (the innermost one) is distinct from the one which does the counting, so using cryptic variable names trying to avoid name collisions isn't even needed. mortee