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 Basics Ruby Syntax Review

Hunter Initiative
Hunter Initiative
27,251 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

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

Hunter Initiative
Hunter Initiative
27,251 Points

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

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

Hunter Initiative
Hunter Initiative
27,251 Points

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

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
27,251 Points

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

You are welcome!

Hunter Initiative
Hunter Initiative
27,251 Points

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

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

Hunter Initiative
Hunter Initiative
27,251 Points

Thanks, just sent a connection to you!