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 trialSteven Saliba
2,667 PointsI need some help. I believe my code is close to passing.
This contact.rb file is part of a larger program. Elsewhere in the program, we've defined a get_name method that takes no arguments, and returns a string.
The code currently in contact.rb creates a contact hash with a "name" key that has an empty string as its value. Update the code to call the get_name method, and assign the return value of get_name to the "name" key in the contact hash.
def get_name
contact_list = []
contact = {"name" => get_name(), "phone_number" => "" }
get_name=["name"]
return contact
end
2 Answers
Steve Hunter
57,712 PointsHi Steven,
You don't want to define a method called get_name
- that's already done according to the question.
This method returns a string, and we want to use that returned value to store against the "name"
key in the hash. So, replace the existing ""
with a call to the get_name
method, as you have done. That's it; just delete the two double-quotes and add a call to the method. Remove your def
and the other additional lines of code - those aren't required.
Steve.
Steven Saliba
2,667 PointsThank you Steve, I will try that.