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 1

I am not sure what I am doing wrong

def mod(a, b) print a % b end

I am confused as to why this is not the correct solution for getting a remainder of a when divided by b

method.rb
def mod(a, b)
  print a % b
end
Ariel Espinal
Ariel Espinal
5,451 Points

From what I understand, the print function is used primarily to print strings on your screen, it does not do any math. However you can print out a VARIABLE* containing math operations.

def example(a, b)
  variable = a % b
  print variable   // Print can only be used either with "" to represent strings or with a variable.
end

Or you can use the return function to return a value.

def mod(a, b)
  return a % b
end

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

It's asking you to return the remainder, not print it

Ty that fixed it