Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Henry Dashwood
PLUS
Henry Dashwood
Courses Plus Student 4,336 Points

Could someone explain where I am going wrong on this method question?

My code is attached. I'm struggling to to get a, b and c to be recognised in the sentence.

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

end

2 Answers

Alistair Mackay
Alistair Mackay
7,812 Points

I got stuck on this one as well, the thing we both tripped on was what the question was asking and the misunderstanding of the difference between "return" & "puts".

I'm still new here, so I don't know how to link my code, that said I can link you to my original question where I got the answer to the problem.

https://teamtreehouse.com/community/stuck-on-modify-return-part-2

Hope this helps!

-PC

Kristopher Van Sant
Kristopher Van Sant
Courses Plus Student 18,830 Points

Hey Alistair! I moved your answer to the answer section so that it can be voted on and so that Henry can potentially mark it as "Best Answer".

Henry Dashwood
PLUS
Henry Dashwood
Courses Plus Student 4,336 Points

Ah yes. I see. I think we must have both been overthinking it!

Alistair Mackay
Alistair Mackay
7,812 Points

Oh yeah, one more thing: I've found that the "help" function on the problems isn't that great on picking up on previous questions asked. The work around for me when I get stuck is to take a note of the exercise name, head to the community forum and write it in there. 9/10 someone else has been stuck on the exact same thing a week earlier.

gl & hf!

-PC