Nothing in the terminal window

Hi,

So I ended up with the following code for this exercise:

creatures = { “weasels” => 0,
“puppies” => 6,
“platypuses” => 3,
“canaries” => 1,
“Heffalumps” => 7,
“Tiggers” => 1
}
puts creatures[“dogs”]

And the response was:

Nothing in the terminal window.
But the following error message was displayed at the bottom of the screen below the code:
Did you try to access a key in the creatures hash that doesn’t exist?

Am I missing something here?
What is the point of this exercise?

The requirement is to " Go ahead and try to access a key in creatures that doesn’t exist."
By using: puts creatures[“dogs”]
I am trying to access a creature that doesn’t exist, yet I am not permitted to go to “Next” as it is still greyed out.

If I input just: creatures[“dogs”] i.e. no puts
Then I am permitted to go “Next”

Confused - I am…

Would appreciate someone explaining why this is the case.

Well, did you? Actually, yes! There is no, ‘dogs’ key in that hash.

Hi,

What I am actually confused about is the fact that my answer was not permitted to be correct when in fact I believe it was.

I should have been able to go to “Next”

What is this?

puts creatures[“dogs”]

It was my attempt to “try to access a key in creatures that doesn’t exist.”
In the same manner that: creatures[“dogs”]
attempts to do the same thing without displaying the resulting value in the terminal panel.

Perhaps I am expecting the parsing of the code for a correct answer to be more complex.
I agree that the displayed error message “Did you try to access a key in the creatures hash that doesn’t exist?” is correct,but it seems to me (happy to be corrected if I am wrong) the actual answer: creatures[“dogs”] should have produced the same error message.

The issue here is that, because of the way the exercise is phrased, the user expects to see some kind of nil result:

What happens if you try to access a key that doesn’t exist, though?

In many languages, you’ll get an error of some kind. Not so in Ruby: you’ll instead get the special value nil .

Just putting creatures[“dogs”] is technically correct because it accesses a nil value, but to a user it’s odd that nothing about this nil value is shown. The exercise after all says you will “get the special value ‘nil’”. Maybe to whoever designed this course it’s obvious that the value needn’t actually appear, but not to the user. This should be made clear, by saying something like “note that the nil value will not show up in the console” or something to that effect.