Koan 代码,编号 75:
in_ruby_version("mri") do
RubyConstant = "What is the sound of one hand clapping?"
def test_constants_become_symbols
all_symbols = Symbol.all_symbols
assert_equal __, all_symbols.include?(__)
end
end
我对此有点困惑,因为我刚刚发现针对“all_symbols.include?(__)”测试的任何符号都将匹配“true”。例如,以下所有内容都应该有效:
assert_equal true, all_symbols.include?(:RubyConstant)
assert_equal true, all_symbols.include?(:"What is the sound of one hand clapping?")
assert_equal true, all_symbols.include?(:AnythingElseYouCouldWriteHere)
用“constants_become_symbols”学到什么?