Victor Shepelev | 5 Jul 00:00
Favicon

[ruby-core:24139] [Bug #1723] respond_to? vs. to_ary

Bug #1723: respond_to? vs. to_ary
http://redmine.ruby-lang.org/issues/show/1723

Author: Victor Shepelev
Status: Open, Priority: Normal
ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32_71]

# class with respond_to? redefined
class A
   def respond_to?(m); false end
end

x = [A.new]

# deconstructing iteration
x.each do |a, b| p [a,b] end

It outputs [nil, nil], while [#<A:0xb5c9d0>, nil] is expected. If I comment out respond_to? in A, all works
as expected

----------------------------------------
http://redmine.ruby-lang.org


Gmane