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 trialBen Santen
1,998 PointsI don't understand how to call a method
please help
3 Answers
Amrit Pandey
17,595 Pointsjust type in the name of method to call it. And that's all!
Eg:
def my_method(name)
puts"My name is #{name}"
end
Now to call my_method,
my_method "Amrit"
Xayaseth Boudsady
21,951 Pointsdef greet
puts "Hello World"
end
greet
just type it in at the bottom.
Edward Danilyuk
8,105 PointsLets setup a method - we will name it say_hello.
def say_hello
puts 'Hello there!'
end
To call the method - type out the name. In our case:
say_hello