Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Loops Build a Simple Contact List Assigning Hash Values From Methods

Sean Flanagan
Sean Flanagan
33,235 Points

Assigning Hash Values from Methods, Task 1

Hi.

Does anyone know why my code doesn't work?

Thanks. :-)

contact.rb
def get_name(kind = "string")
  contact_list = []
  contact = {"name" => "", "phone_number" => "" }
end

1 Answer

John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hi Sean,

I'm afraid that's not what the question is asking for at all.

It's asking you to assign the value of the key "name" to the return of the get_name() method.

There's no need to define any methods, we are assuming that a method is already pre-defined.

Try something like:

contact = {"name" => get_name(), "phone_number" => "" }

Hope this helps.