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 trialmelisa pettaway
9,556 Pointsruby basics methods
having issues on the remainder code challenge. i have put in #{a} #{b} #{c} but it keeps saying my punctuation is wrong. tried it in workspace and it gave me the correct value. i am not quite sure what im doing wrong.
3 Answers
David Abel
5,199 PointsIt should look something like this:
def mod(a, b)
c = a%b
return "The remainder of #{a} divided by #{b} is #{c}."
end
Tim Knight
28,888 PointsMelisa,
Make sure you have a period on your sentence, that sometimes causes a failure. Basically it should look like:
def mod(a, b)
c = a % b
"The remainder of #{a} divided by #{b} is #{c}."
end
or you could leave out the c
variable with:
def mod(a, b)
"The remainder of #{a} divided by #{b} is #{a % b}."
end
melisa pettaway
9,556 Pointsthanks everybody! i forgot the period at the end. lmbo!!!
Tim Knight
28,888 PointsTim Knight
28,888 PointsOne thing to note David is that it's more idiomatic Ruby to not state a
return
—Ruby automatically returns the last value within the method.