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 trialLoi Tran
9,053 Pointsprint_results a part of the public domain?
Hey guys, does anyone here know if 'print_results' is in the public domain? I don't know why this isn't executing. code. https://gist.github.com/Lvtran1987/d6322db131c037045184 The only credible source I found/am familiar with says yes, however the github link it gives us is no longer a working page, so I'm pretty sure the page has been removed, unless github now blows and cant program well? Haha. Rubydoc page http://www.rubydoc.info/github/opscode/chef/Chef%2FKnife%2FList%3Aprint_results missing page https://github.com/chef/chef/blob/Chef%2FKnife%2FList%3Aprint_results/lib/chef/knife/list.rb#L123
3 Answers
Greg Yardley
4,236 PointsAh ha! Sorry, I was just looking at the top-level forum while drinking my morning coffee.
If Jason uses it, it's almost certainly got to be a method he's already written somewhere. I took a quick peek at the course, and it looks like the print_results method is included in the Teacher's Notes section of the Searching by Phone Number video:
def print_results(search, results)
puts search
results.each do |contact|
puts contact.to_s('full_name')
contact.print_phone_numbers
contact.print_addresses
puts "\n"
end
end
Greg Yardley
4,236 PointsHi! You've linked to some documentation for a method that's part of third-party program called Chef, which is written in Ruby but not actually part of Ruby itself.
Unless you've specifically added a third-party program in your code, you'll want to stick to using methods that are either part of Ruby itself or ones you've written as part of your program. Documentation for the core Ruby methods is here: http://ruby-doc.org/
In your case, you probably want to use the 'puts' or 'print' methods to output to the screen. You might also want to use a loop of some kind to go through each element of the results array, outputting each in turn.
Loi Tran
9,053 PointsGreg, I understand everything you said. And I have tried to do the puts and print method. However the print_result is part of a query. This is the address book exercise we do in Ruby. If it isn't a part of the public domain why does Jason use it..? He uses it in the exercise when we're trying to add the method to our address_book which allows us to find_by_address.
Thanks for taking the time to respond!
Loi Tran
9,053 PointsLoi Tran
9,053 PointsHm. I seem to have written my code differently for the find_by_phone. This yielded me the results I wanted. Haha. I often work ahead in order to figure out whether or not I'm actually any good at this (My way of evaluating myself)
That being said, heres my link. https://gist.github.com/Lvtran1987/1f3447ad6137ac8ea360 When you suggested that I look at the find_by_phone method and I saw different code than his then I just decided to copy and paste mine over... and now the find_by_address method works =). Thanks~!