Doing the Ruby Koans, in the file about_symbols
at line 88, I'm not sure of the answer.
This is the code:
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
The point of the Ruby Koans is to learn by reading and trying things out.
Open up a terminal and start irb
. Then try using the +
operator on two symbols. Check the error you get and substitute it as appropriate in the Koans file.
Assuming that your prompt ends in $
, that will look something like this:
$ irb
irb(main):001:0> :cats + :dogs
The answer you need will be clear pretty quickly in the error that irb
spits out.
To go through step by step in case your completely new to Ruby you could try:
- Open up a terminal
- Type
irb
at your prompt to get to the interactive ruby prompt- This is where you can quickly try out different Ruby things
- Type the command in question
:cats + :dogs
- Review the output which will look like
NoMethodError: undefined method `+' for :cats:Symbol from (irb):1
The name of the exception thrown which is what you are looking for is the first thing e.g. NoMethodError
精彩评论