Skip to content

Answer is incorrect #65

@ncaron

Description

@ncaron

http://www.codequizzes.com/ruby/beginner/symbols-array-methods-hashes

What does the following code return?

snowy_owl = { "type"=>"Bird", "type" => "Owl", "diet"=>"Carnivore", "life_span"=>"10 years" }
puts snowy_owl

Answer

{"type"=>"Owl", "diet"=>"Carnivore", "life_span"=>"10 years"}
Notice that the second key/value pair with the key "type" is included. Every key in a hash must be unique.

But puts always returns nil. So the answer on the site is incorrect or it should be asking what does it print.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions