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 trialShaun Lennon
5,028 PointsHow do I define a method called say_hi?
Define a method named say_hi. The method body should include a call to puts with an argument of "hi". Then call your new say_hi method.
def say_hi
puts "hi"
say_hi
end
1 Answer
Steven Parker
231,271 PointsThe definition of the method is OK. But when the instructions asked "then call the method", they meant do it after the definition (after the "end").
Doing it inside causes it to call itself over and over (known as a "recursion loop") and creates an error.