在Ruby中使用+符号时会引发什么异常?

0 ruby exception

在第88行的文件中做Ruby Koans,about_symbols我不确定答案.

这是代码:

def test_symbols_cannot_be_concatenated
    # Exceptions will be pondered further farther down the path
    assert_raise(what should i put?) do
      :cats + :dogs
    end
Run Code Online (Sandbox Code Playgroud)

Tel*_*hus 5

该点红宝石Koans是通过阅读和尝试的事情了学习.

打开一个终端然后开始irb.然后尝试+在两个符号上使用运算符.检查您获得的错误并在Koans文件中根据需要替换它.

假设你的提示结束$,那将看起来像这样:

$ irb
irb(main):001:0> :cats + :dogs
Run Code Online (Sandbox Code Playgroud)

你所需要的答案会很快清楚地显示出来的错误irb.