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 trialDewayne Whitfield
1,423 PointsI know the code is right that I am putting in for this problem. I tested it in the workspace. Please help.
If anyone can help me let me know.
def mod(a, b)
c = a % b
puts "The remainder of #{a} divided by #{b} is #{c}"
end
5 Answers
Zach Swift
17,984 PointsYou are very close!
You are missing a period at the end of the sentence AND they're asking you to return it. I think they're looking for the 'return' keyword.
Zach Swift
17,984 Pointsjust replace the 'puts' keyword with 'return' and that made it pass for me.
Zach Swift
17,984 Pointsdef mod(a, b)
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
that's what I mean. Is that what you tried?
Dewayne Whitfield
1,423 PointsThat worked. Thanks!
Alan Matthews
10,161 PointsSee above. The return
is not necessary as Ruby always returns the last evaluated expression.
Dewayne Whitfield
1,423 PointsThanks Alan. I put in the period and it didn't work. Is there anything else I am missing?
Zach Swift
17,984 PointsThat's very true, but I believe they are looking for the return keyword. Because it passes only with 'return' .
Alan Matthews
10,161 PointsSorry if I confused everyone. Use return
instead of puts
or print
in order to make the exercise pass. I was just mentioning that normally you would not need to use return
since Ruby will evaluate the last expression and return that.
Dewayne Whitfield
1,423 PointsI know how to return, but how would I get it in the string?
Dewayne Whitfield
1,423 PointsDewayne Whitfield
1,423 PointsOk. Let me try that.
Dewayne Whitfield
1,423 PointsDewayne Whitfield
1,423 PointsThat didn't work. I added the period. It also asks to display "c".