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 trialTyler Martin
3,535 PointsProblem with Ruby Code Challenge
Create a method called "mod" that takes two arguments, "a" and "b", and returns the remainder of "a" when divided by "b". Hint: remember the "%" operator!
def mod(a,b)
return a % b
end
mod (3,2)
This is what I did and it gives me an error. I feel like I'm missing something obvious here.
5 Answers
Nathan Williams
Python Web Development Techdegree Student 6,851 PointsHi Tyler,
You wouldn't want to put a space between the function name and the parentheses that wrap your parameters
i.e.
mod(3,2)
but not
mod (3,2)
Hope that helps!
Annie Scott
27,613 Pointsdef mod(a, b) return a % b end
Tyler Martin
3,535 PointsThank you that did it!
dr disrespekt
2,010 PointsThx I needed help on this to I just had puts instead of return. How do we know the difference when asked to write a method?? Im good at everything all the syntax but when asked to do something im clueless the wording stumps me.
lina Hernandez
4,583 Pointsdef mod(a,b) return a % b end
mod (3,2)