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 trialhighlandcow
7,352 PointsGetting the Ruby method lingo down
I want to make sure I understand all these terms, so I took a stab at describing each line in this video's example code. Can someone check my "translation"? :) .
1. def add(a)
Defines method "add" which takes argument "a"
2. puts a + 2
Somewhat struggling with this one, oddly enough. Definition of method add: writes a + 2.
3. end
Key word ending the definition of method "add".
4. add(2)
Calls method "add", passing "2" for argument "a".
Thank you!
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey there,
Yep, you seem to have everything down for basic method syntax.
To help with #2, puts
(which stands for "put String") is essentially the same as print
. Both will output to the screen, it's just that puts
will add a new line after execution and print
will not. So, try not thinking it as "puts" but rather "put string" on the screen... it may make it seem to make more sense.
Great Job! :)
highlandcow
7,352 Pointshighlandcow
7,352 PointsThanks! In hindsight, "put String" should've been obvious, ah well!