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

not seeing my mistake

did I actually make a mistake

method.rb
def mod(a, b)
  puts "returning c which is the remainder of the division of #{a} and #{b}"
  return a % b = c #write your code here
end

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi There.

There are a few of mistakes happening here.

  • First, the challenge wants you to return the string, and you are using puts.
  • Second, the challenge wants you to return a very specific string, which you are not.
  • Third, the formula used to find the modulo needs to come before the string in order for the string to work with interpolation, and the challenge did not want the formula returned.

Below is the corrected code for your reference. I hope it makes sense.

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

Keep coding! :)

:dizzy:

Thank you I see the difference. I was returning the equation instead of the sentence.