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

Assign the value of the key name to the return value of the method get_name() in the contact hash. Assume that get_name(

I've been stuck on this question for a while

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

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points
contact_list = []

contact = {"name" => get_name, "phone_number" => get_phone_number }

ohhh lol. much easier than i thought.

thanks!

ARNOLD SANDERS
ARNOLD SANDERS
5,266 Points
def get_name
    contact = {"name" => "Joe", "phone_number" => "" }
   return contact["name"] 
end

and then call it:

get_name

Thanks!