我正在研究以下Ruby Koan:
class Dog7 attr_reader :name def initialize(initial_name) @name = initial_name end def get_self self end def to_s __ end def inspect "<Dog named '#{name}'>" end end def test_inside_a_method_self_refers_to_the_containing_object fido = Dog7.new("Fido") fidos_self = fido.get_self assert_equal "<Dog named 'Fido'>",fidos_self end def test_to_s_provides_a_string_version_of_the_object fido = Dog7.new("Fido") assert_equal __,fido.to_s end
第一个assert_equal的前半部分是我要填写的内容.此代码给出了错误:
<"<Dog named 'Fido'>"> expected but was <<Dog named 'Fido'>>.
问题是,我坚持如何匹配返回值.它看起来像一个字符串字面值返回值,但我不知道如何表达,而不使用引号,和/或反斜杠.没有什么我尝试似乎工作.
帮帮我?