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

AMIRALI PUNJANI
AMIRALI PUNJANI
2,032 Points

"Make sure you return a nicely formatted string" is the error I'm receiving.

I created the value of 'c' and typed the text as instructed, and yet I'm receiving the error.

method.rb
def mod(a, b)
  #write your code here
  c=a% b
  puts "The remainder of #{a} divided by #{b} is #{c}"
end
mod(3, 2)

3 Answers

Jesse James
Jesse James
6,079 Points

There are actually two problems here causing this not to pass through:

  1. The challenge is asking you to return the string but you're using put. Change that to return :)

  2. You're missing the period (.) at the end of the sentence which it seems to require as well.

Nicholas Kim
Nicholas Kim
3,588 Points

period !!!!!!!! That was so..

AMIRALI PUNJANI
AMIRALI PUNJANI
2,032 Points

Got it, Thanks for the help.

Wade Christensen
STAFF
Wade Christensen
Treehouse Teacher

I just wanted to add that you can also do the math right in the string. Ruby will interpret it properly. For example, you could write:

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