Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

def mod(a, b)
  print a % b
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.

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

def mod(a, b)
  return a % b

1 Answer

Kevin Korte
Kevin Korte
28,109 Points

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

Ty that fixed it