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 Functions in Swift Adding Power to Functions Function Parameters

Daniella Flores
PLUS
Daniella Flores
Courses Plus Student 2,248 Points

Hi, the system isn't accepting my code for Functions Scope Challenge 2 of 2. Can anyone please help?

What am I doing wrong?

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

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

2 Answers

andren
andren
28,558 Points

The issue is that you wrapped the return type of the function in parenthesis which you were not supposed to do. That is an issue that should have been caught during Task 1 but the task checker can let some issues through from time to time.

If you remove the parenthesis like this:

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

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

Then your code will work.