Silly Code from The Muppet Laboratories

... for lazy typers - can also be used for obfuscation. Might make your code unmaintainable, instable or both.

Use at own risk.

  robert

silly-1.rb (837 Bytes)

This was a Ruby Quiz just the week before last:

http://www.rubyquiz.com/quiz110.html

James Edward Gray II

···

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

Heh, who needs gems? Soon the answers to all problems will have been
solved as a quiz at some point. :slight_smile:

···

On Feb 2, 12:08 pm, James Edward Gray II <j...@grayproductions.net> wrote:

This was a Ruby Quiz just the week before last:
Ruby Quiz - Method Auto Completion (#110)

Umpf! I better stop posting now in order to prevent more embarrassment...

  robert

···

On 02.02.2007 20:08, James Edward Gray II wrote:

This was a Ruby Quiz just the week before last:

http://www.rubyquiz.com/quiz110.html

James Edward Gray II