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

The Mod method could not be found

I put in this code but it doesn't seem to work

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

11 Answers

It should't be?

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

Nope, doesn't work

I think it is not compiled because you have % instead of /.

not sure though

Im supposed to find the remainder so...

sorry... not paying attention

Wouldn't that be the same thing? Anyways, I'll try it out. Thanks

What's the error?

Bummer! The mod method could not be found.

Weird. When I run the code in the challenge it passes. You are running locally?

Locally?

Would you mind posting the code you ran?

Sure my friend. It's the same that I posted first:

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

Another Error is: Bummer! NameError: undefined local variable or method `c' for main:Object

With this code:

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

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

That code gives me this error: Bummer! Something doesn't look quite right. Double check your spelling and punctuation.

Sorry. The challenge need's of the pontuaction at the end :)

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

Lets hope that's not what I was stuck on for 3 hours...

Lol. That was what I was stuck on for 3 hours! Thanks man! You really helped me out!

Thanks Luis.. I was stuck on this for two days.. ugh