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

Not able to proceed

For the question: Use string interpolation to return the remainder inside the sentence “The remainder of a divided by b is c.” where a is your “a” variable, b is your “b” variable, and c is the value of a % b.. This is the code I wrote: def mod(a, b)
puts "The remainder of #{a} divided by #{b} is"
return a % b end puts mod(3,2). The code seems to be verified and the result displayed but the 'recheck' work doesnt allow me to proceed with this error "The return string is not nicely formatted" tried various combinations but could not proceed

method.rb
def mod(a, b)

       puts "The remainder of #{a} divided by #{b} is"

return  a % b
end


puts mod(3,2)

2 Answers

Ian Bowers
Ian Bowers
3,665 Points

You're probably missing a space behind #{b} is"

Thanks for your reply..I just tried various combinations and finally I understood that I was supposed to give the 'return' statement as a string instead of the 'puts'. When I did that it passed through successfully.