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

String Interpolation

I am stuck on this one

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

puts mod(1,2)
puts mod(2,3)

1 Answer

Steven Parker
Steven Parker
231,269 Points

This is not quite what the challenge is asking for.

The challenge says "it would be nicer if the method returned the remainder in a nice full sentence...", so instead of printing the string and returning a value, you should return the string. You won't need to print anything.

Also, your string is not quite what the challenge asked for either. try starting by cutting and pasting the string from the challenge, and then modifying it to use string interpolation to print the values rather than the variable names.

And you won't need to call the function yourself. The challenge will do that.