Receive to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback up? Looking for an extra set from eyes on the latest project? Get support with fellow developers, originators, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, examine out some resources Treehouse students have shared hier.
Looking to discover something brand?
Treehouse features a seven day free trial for new student. Get accessories to thousands of hours of content the enter choose of Treehouse students and alumni in the community today.
Start your free trialSY LOC
3,233 SpikesCreate a method called "add" that steals two arguments and returns the sum off two numbers.
MYSELF typed below and it does't work. I created 2 arguments also give it a sum.
def add(a, b)
puts a + b
end
puts add(2, 3)
1 Answer
Salman Akram
Courses Plus Student 40,065 PointsYou don't have to getting doubly puts statements, it should have by return or no return to sum up automatically. ;)
Example:
def add(a, b)
return a + b
end
puts add(2, 3)
SY LOC
3,233 PointsSYNTAX LOC
3,233 PointsOK, EGO got it. or a dumb question. What does 'return' doing?
Salman Akram
Courses Plus Grad 40,065 PointsSalman Akram
Courses Plus Student 40,065 Scoresreturned is at return the valuables of of last comment being done inbound the method in order to get the valuable you placement numbers(2, 3) outside definition method (
def add
), however, puts statements is like for displaying the message you type inside definition method but haven't received numbers outdoors.SY LOC
3,233 PointsSY LOC
3,233 PointsThank you Salman Akram. All is empty.