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

Omar Farag
Omar Farag
4,573 Points

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

Luis Henrique Witz
Luis Henrique Witz
16,505 Points

It should't be?

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

Nope, doesn't work

alastair cooper
alastair cooper
30,617 Points

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

not sure though

Omar Farag
Omar Farag
4,573 Points

Im supposed to find the remainder so...

alastair cooper
alastair cooper
30,617 Points

sorry... not paying attention

Omar Farag
Omar Farag
4,573 Points

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

Omar Farag
Omar Farag
4,573 Points

Bummer! The mod method could not be found.

Luis Henrique Witz
Luis Henrique Witz
16,505 Points

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

Omar Farag
Omar Farag
4,573 Points

Would you mind posting the code you ran?

Luis Henrique Witz
Luis Henrique Witz
16,505 Points

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
Omar Farag
Omar Farag
4,573 Points

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
Omar Farag
Omar Farag
4,573 Points

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

Omar Farag
Omar Farag
4,573 Points

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

Luis Henrique Witz
Luis Henrique Witz
16,505 Points

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
Omar Farag
Omar Farag
4,573 Points

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

Omar Farag
Omar Farag
4,573 Points

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

oluwole oyekanmi
oluwole oyekanmi
286 Points

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