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 trialisaacpollock
1,023 PointsI can't remember the operator that gives me the remainder of the operator
please answer this as soon as possibl
def mod(a, b)
puts mod/b
end
3 Answers
Steve Hunter
57,712 PointsThis code will pass that challenge - I just looked it up for you:
def mod(a, b)
return a % b
end
You need to return the result of the modulus operation from the method.
Steve.
Steve Hunter
57,712 PointsDo you mean the % operator?
Gaetano Ferrara
5,191 PointsActually Ruby automatically returns the result of the last expression evaluated, so why should we manually return the value?
Steve Hunter
57,712 PointsYeah - good point. I've been in Java all week so forgot that. Some would say adding the explicit return keyword adds clarity; others would say it doesn't. The code challenge accepts either version.