From: Run Paint Run Run Date: 2009-10-14T20:07:52+09:00 Subject: [ruby-core:26087] [Bug #2212] Using a Lambda with Inappropriate Arity for Hash#default_proc= Bug #2212: Using a Lambda with Inappropriate Arity for Hash#default_proc= http://redmine.ruby-lang.org/issues/show/2212 Author: Run Paint Run Run Status: Open, Priority: Low Category: core ruby -v: ruby 1.9.2dev (2009-10-14 trunk 25330) [i686-linux] If the default_proc of a Hash is a lambda whose arity != 2, key lookups raise an ArgumentError. To understand this exception the user must know that the hash has a default proc, lambdas perform strict argument checking, and that the lambda is passed two arguments. Instead, perhaps Hash#default_proc and Hash.new could raise a helpful error message if they're passed a lambda with an arity other than 2. This localises the exception to where the default_proc is set, as opposed to where an element is referenced, and better explains the problem. >> h={} => {} >> h.default_proc=->{ true } => # >> h[:key] ArgumentError: wrong number of arguments (2 for 0) from (irb):13:in `yield' from (irb):13:in `default' from (irb):13 from /usr/local/bin/irb:12:in `
' ---------------------------------------- http://redmine.ruby-lang.org