4/15 green-lights, but doesn't print to the console properly


#1

My nil substitute does not print to the console, why not? I still get 'nil' (but the lesson green-lights).

no_nil_hash = Hash.new("Pikachu!")

creatures = { "weasels" => 0,
  "puppies" => 6,
  "platypuses" => 3,
  "canaries" => 1,
  "Heffalumps" => 7,
  "Tiggers" => 1
}

creatures["Pika"]

#2

Well, your hash with the default value "Pikachu!" is called "no_nil_hash", so if you don't use "no_nil_hash", you'll never return the default value you're expecting ^^.

So try with:

no_nil_hash["Pika"]

#3

You started off using constructor notation, and then switched to literal notation. Like arjofocolovi mentioned, you should use the constructor notation. Below is the example I used.

no_nil_hash = Hash.new("MyDefaultValue")

no_nil_hash["dog"] = "Stanley"
no_nil_hash["cat"] = "Felix"
no_nil_hash["bird"] = "Simon"

no_nil_hash["bigfoot"]