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 trialNigel Matheson
Courses Plus Student 1,166 Pointsstuck on this question regarding functions
i know i'm close but just not close enough regarding functions question
// Enter your code below
func getRemainder (a: value, b:divisor) return: Int
2 Answers
tromben98
13,273 PointsHi Nigel!
I think that you should repeat the previous videos in order to learn about return types and parameter names
Best regards, Jonas
// Enter your code below
func getRemainder (value a: Int, divisor b: Int) -> Int {
return a % b
}
Habib Miranda
7,320 PointsYou are creating a return type the same way you are creating a function parameter. The Parameter of the function (what's inside the parenthesis) require a name. For example:
function nameOfFunc(nameOfParam1: Int, nameOfParam2: Int) {
}
Now in order to add a return type to the function, you simply add the return type without naming it. It looks like you are trying to assign a name to your return. You don't need to name it with the name: Type syntax. You simply need to declare what type it is with the -> Type syntax. See the example:
function nameOfFunc(nameOfParam1: Int, nameOfParam2: Int) -> Int {
return nameOfParam1 % nameOfParam2
}