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

I don't get what this is asking me to do

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

contact.rb
contact_list = []

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

2 Answers

In most of these, the answer is within the question. Don't overthink it. :)

contact_list = []

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

i'm dumb. haha. thank you!

Firstly, you're not dumb. We all make silly mistakes like this and that's why most companies employ teams of developers instead of just one. It's easy to overlook things like these and sometimes it takes a fresh perspective.

Secondly, you're quite welcome. You could repay Me by selecting My answer as "Best Answer". I'm trying to get My forum points to complete the course.

Happy coding, jordanresendiz!

The question is somewhat misleading because of this unknown "get_name" method. Are you suppose to be defining a method or are you merely assigning a value to a variable? It turns out to be the later, and the question might be made clearer if they asked,

"Make a variable 'get_name'. Set the value of get_name to the value of "name" key in the contact hash."