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 trial

Ruby Ruby Basics (Retired) Ruby Methods Method Returns: Part 2

david kennedy
david kennedy
2,291 Points

Don't understand why this is wrong: “The remainder of #{a} divided by #{b} is #{c}.” end

def mod(a, b) puts a % b “The remainder of #{a} divided by #{b} is #{c}.” end

method.rb
def mod(a, b)
  c = puts a % b
  The remainder of #{a} divided by #{b} is #{c}.”
end

2 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey there,

you're trying to save the puts statement inside of the variable c. However you want to save the remainder in the c variable so you should leave away the puts and just calculate it. I also noticed that you're not using "normal" quotes, that's also the reason why the code highlighting doesn't work correctly. Make sure to use the right quotes and it should look like this:

def mod(a, b)
  c = a % b
  "The remainder of #{a} divided by #{b} is #{c}."
end

I hope that helps, if you have further questions feel free to ask! :)

david kennedy
david kennedy
2,291 Points

Great! thanks so much that completely makes sense.