From: Rick DeNatale Date: 2007-10-30T02:05:00+09:00 Subject: Re: Skip the first invocation e.g. skip_first { foo } On 10/29/07, Pit Capitain wrote: > Hi Brian, sorry for the late reply. Here's something with a simpler > calling syntax: > > module SkipN > @callers = Hash.new(0) > def self.skip(n = 1, key = caller.first) > yield if (@callers[key] += 1) > n > end > def self.skip_first > skip(1, caller.first) { yield } > end > end Bravo! > Note that this only works in simple cases. For example it's not thread-safe. It also leaks memory since the @callers class instance variable never has the keys deleted. But cool nonetheless. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/