From: Dave Thomas <Dave / PragmaticProgrammer.com>
Subject: [ruby-talk:8925] Re: bug??
Date: Tue, 9 Jan 2001 23:09:54 +0900

> matz / zetabits.com (Yukihiro Matsumoto) writes:
> 
> > |I agree. But should we have way to change the hash default initializer?
> > 
> > Not really.  Hash default value (single object given to `Hash::new')
> > and hash fallback (block given to `Hash::new') are two similar yet
> > different beasts.  And code portion by block may not be replaceable
> > later in many other cases.
> 
> Except we could have the best of both worlds: if the default value was 
> a proc, then it could be called to supply the value to use.

Does not this change break code like bellow?

  call_back_table = Hash.new(proc {|*|})

  call_back_table["foo"] = handler.method(:foo)
  call_back_table["bar"] = handler.method(:bar)

  while(line = gets)
     keyword, *args = line.split
     call_back_table[keyword].call(args)
  end

Although I have not done this in a real code, it looks a legitimate
use of the default mechanism.

Kenich Komiya.