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

iOS Swift 2.0 Functions Function Parameters Function Parameters

"Step 1 - Make sure your function accepts two parameters", what am I doing wrong?

I have declared the function as instructed, but when I compile it, it shows as an error. What should I correct in this code?

1 Answer

Nathan Tallack
Nathan Tallack
22,160 Points

You will recall that by default when you declare a function the external variable names will match the function argument names. Also you will recall that by default the first argument name is not required. That would look something like this.

func getRemainder(a: Int, b: Int) -> Int {
    return a % b
}

let result = getRemainder(10, b: 3)

This challenge is trying to show you those two things. First that you can give external argument names to help the user of your function understand what the arguments are (better than a and b) and second that when you give an external argument name to the first argument then it must be used when calling the function. It would look something like this.

func getRemainder(value a: Int, divisor b: Int) -> Int {
    return a % b
}

let result = getRemainder(value: 10, divisor: 3)