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

Raul Grigoriu
Raul Grigoriu
1,060 Points

Help on a challenge!

Bummer! Make sure you return a nicely formatted string.

I do not really understand what is not nice in my string really? Can somebody illuminate me please?
Thank you in advance!:)

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

puts mod(5, 9)

3 Answers

You are actually not returning your answer as a string. You are printing (puts) a string and then returning just the answer. Try returning the string with your answer:

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

puts mod(5, 9)

Also make sure all your string interpolations have a hash(#) in front of them. Let me know if you still have questions.

Raul Grigoriu
Raul Grigoriu
1,060 Points

Thanks a million Ryan, for now I am good to go but I am most sure in the future...

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi Raul - There should only be a return statement inside the method which returns the sentence "The remainder of a divided by b is c." Use string interpolation inside that string to replace a, b, and c with their actual values and don't display anything.

Raul Grigoriu
Raul Grigoriu
1,060 Points

Thank for your quick reply Kourosh! :)