From: James Edward Gray II Date: 2007-02-03T04:08:12+09:00 Subject: Re: Silly Code from The Muppet Laboratories On Feb 2, 2007, at 1:00 PM, Robert Klemme wrote: > module Kernel > alias _method_missing method_missing > > def method_missing(s,*a,&b) > candidates = method_candidates(s) > case candidates.size > when 0 > _method_missing(s,*a,&b) > when 1 > send(candidates[0],*a,&b) > else > raise NameError, > "Ambiguous name: #{s}, "\ > "candidates: #{candidates.join ', '}" > end > end > > private > # find names of which sym is prefix > def method_candidates(sym) > methods.grep(/\A#{sym}/i) > end > end This was a Ruby Quiz just the week before last: http://www.rubyquiz.com/quiz110.html James Edward Gray II