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

Matt Schroeter
Matt Schroeter
976 Points

It seems like I've declared both parameters and the external parameters right here - what's missing?

Wondering what I'm missing here with my current setup for the function.

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

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Matt.

Your code is correct in syntax, except you have your local and external parameters backwards.

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

You want a and b to be local so it's easier to code in the function, but you want value and divisor to be external, so when the function is called, it is easy to know what 'values' to enter.

Hope that makes sense. Keep coding! :)

Matt Schroeter
Matt Schroeter
976 Points

Ah now I get it. Thanks!