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 trialBrandon Jacobi
4,702 PointsWhat is the Difference between Methods in ruby and Functions in JavaScript?
In javaScript functions can be called for certain instances. In Ruby is a method as seen below the same thing like function in JavaScript?
def add
puts 2 + 2
end
add()
1 Answer
Alexander Davison
65,469 PointsBingo! Methods and Functions are exactly the same thing. They are just two different ways to say a function (or method). Another note: In many programming languages (including Python, PHP, Java, C#, etc.) functions are called... uh... functions, but those functions in classes (which you will learn soon in your journey of programming) are called methods. But in Ruby, all functions are called methods.
:) ~ Alex
Brandon Jacobi
4,702 PointsBrandon Jacobi
4,702 PointsThanks for helping me clarify that!
Alexander Davison
65,469 PointsAlexander Davison
65,469 Pointsyour welcome! Can you see my update please (I updated the answer)? Thanks! ~alex