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

Im not quite sure what Im doing wrong here

Im unsure to why this is happening and have looked through the code but can't seem to figure out why its not working. any way someone can help and explain what I am doing wrong it would be great thanks!

method.rb
def mod (a, b ) 
  puts "Dividing #{a} and #{b}:"
  return b % a
end

puts  mod (3 , 2 ) 

2 Answers

Hi Tommy

Errors:

  • many spaces like mod (a, b...), puts....mod (3 , 2...)
  • b % a reverse
  • don't need "puts" on the last line.
def mod(a, b) 
  puts "Dividing #{a} and #{b}:"
  return a % b
end

mod(3, 2) 

As soon as you sent It I've realized it now, really helpful thankyou!