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.

iOS Functions in Swift Adding Power to Functions Function Parameters

Sebastian Fernandez
Sebastian Fernandez
2,413 Points

What is a module?

Hi!, I stuck in this exercise because, what is a module?

pls Help!!

// Enter your code below
func getRemainder(value a:Int, divisor b:Int ) -> Int {
    let modulo = a / b
    return modulo
Michael Hulet
Michael Hulet
47,843 Points

Can you clarify what you're asking a bit? You ask about what a module is, but your code implies that you mean that you're wondering what the modulo operator (%) does, and these are 2 entirely disparate and unrelated concepts in Swift

1 Answer

28,526 Points

The modulo operator (technically called the remainder operator in Swift) was covered in the Arithmetic Operators video back in the Swift Basics course.

But to offer a quick recap, it looks like the percentage symbol % and gives you the remainder of dividing two numbers. So 4 % 3 for example would result in 1.

All you need to change in your code to pass the task is to replace the / symbol with %.