From: Yui NARUSE Date: 2011-08-05T11:17:07+09:00 Subject: [ruby-core:38809] [Ruby 1.9 - Bug #5158][Assigned] to_ary not respecting respond_to? Issue #5158 has been updated by Yui NARUSE. Status changed from Open to Assigned Assignee set to Nobuyoshi Nakada ---------------------------------------- Bug #5158: to_ary not respecting respond_to? http://redmine.ruby-lang.org/issues/5158 Author: Ryan Davis Status: Assigned Priority: Normal Assignee: Nobuyoshi Nakada Category: Target version: ruby -v: - class BadProxyObject def initialize @p = Object.new def @p.to_ary raise "I should never be called" end end def respond_to?(*a) p :bad_respond_to? => a false end def method_missing(msg, *) p :bad_method_missing => msg @p.send msg end end [[BadProxyObject.new]].flatten # {:bad_method_missing=>:to_ary} # Exception `RuntimeError' at wtf.rb:6 - I should never be called # wtf.rb:6:in `to_ary': I should never be called (RuntimeError) # from wtf.rb:17:in `method_missing' # from wtf.rb:21:in `flatten' # from wtf.rb:21:in `
' Extra Info: http://tenderlovemaking.com/2011/06/28/til-its-ok-to-return-nil-from-to_ary/ -- http://redmine.ruby-lang.org