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

Ruby Basics

What am I doing wrong in Ruby Basics, Method Returns: Part 1 - Task 2?

method.rb
def mod(a, b)
  return a / b
end

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're returning the result of dividing two numbers. What you need to be returning is the remainder after two numbers are divided. For example, 9 divided by 4. Your code would return 2.25 But what we want it to return is 1. Nine is divisible by four two times with a remainder of one. We do this with the modulus/remainder operator.

Here's a quote from the challenge instructions

Hint: remember the "%" operator!

Hope this helps! :sparkles:

Thank you! :)