我正在关注Ruby Koans的练习,about_proxy_object_project.rb
其中有一段代码:
class Proxy
def initialize(target_object)
@object = target_object
end
# This method was added by me
def method_missing(method_name, *args, &block)
@object.send method_name
end
end
这被称为:
def test_tv_methods_still_perform_their_function
tv = Proxy.new(Television.new) # Television is a class with a :channel attr_accessor and a power method
tv.channel = 10
tv.power
assert_equal 10, tv.channel
assert tv.on?
end
问题是该行tv.channel = 10
正在“破坏”解释器并抛出:
[BUG] Stack consistency error (sp: 53, bp: 54)
ruby 2.0.0p0
(...)
full stack trace follows
我已经用 Ruby 1.9.3 尝试了相同的代码并且它正在工作。我正在使用 Ruby 2.0.0-p195。
那么,这是一个错误/错误吗?还是我做错了什么?