Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Basics Ruby Syntax Review

Hunter Initiative
Hunter Initiative
20,747 Points

methods 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
Shem Ogweno
13,563 Points

Puts method will print out a string to a terminal then RETURNS "nil"!

Hunter Initiative
Hunter Initiative
20,747 Points

Yeah sure, new to Ruby have tried with irb have seen the #welcome method having different output from the rest!

Shem Ogweno
Shem Ogweno
13,563 Points

Hi Hunter, Are you still having trouble understanding the point of this question?

Hunter Initiative
Hunter Initiative
20,747 Points

Yeah because it's already outputting a string and additional nil

Shem Ogweno
Shem Ogweno
13,563 Points
def 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
Hunter Initiative
20,747 Points

Thanks for taking me through this! I really appreciate:)

Hunter Initiative
Hunter Initiative
20,747 Points

Would really appreciate if you will hold my hand in this journey of programming!

Shem Ogweno
Shem Ogweno
13,563 Points

Send a connect on linkedin! There is a link on my profile.

Hunter Initiative
Hunter Initiative
20,747 Points

Thanks, just sent a connection to you!