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!
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

Hunter Initiative
27,251 Pointsmethods that will NOT return the string "hello"
def greet return "hello" end
def acknowledge "hello" end
def welcome puts "hello" end
7 Answers

Shem Ogweno
15,392 PointsPuts method will print out a string to a terminal then RETURNS "nil"!

Hunter Initiative
27,251 PointsYeah sure, new to Ruby have tried with irb have seen the #welcome method having different output from the rest!

Shem Ogweno
15,392 PointsHi Hunter, Are you still having trouble understanding the point of this question?

Hunter Initiative
27,251 PointsYeah because it's already outputting a string and additional nil

Shem Ogweno
15,392 Pointsdef greet return "hello" end # Will return 'hello' because you explicitly use the return keyword.
def acknowledge "hello" end # Ruby methods ALWAYS return the last line of the expression unless return comes before it.
def welcome puts "hello" end # This method is printing 'hello' then return 'nil'
Hope this will help!

Hunter Initiative
27,251 PointsThanks for taking me through this! I really appreciate:)

Shem Ogweno
15,392 PointsYou are welcome!

Hunter Initiative
27,251 PointsWould really appreciate if you will hold my hand in this journey of programming!

Shem Ogweno
15,392 PointsSend a connect on linkedin! There is a link on my profile.

Hunter Initiative
27,251 PointsHey, what's your user name?

Shem Ogweno
15,392 PointsHere is my linkedin: https://www.linkedin.com/in/shemogweno

Hunter Initiative
27,251 PointsThanks, just sent a connection to you!