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 Scope

function Scope when i input the code that Pasan is doing it raise an error

func countDownAndUp(var a: Int) { var b = a

while b >= 0 { b--
a++ print("a: (a)") print("b: (b)")

} } var a = 20 countDownAndUp(10)

it raise me an error when i add var to the parameter because it says that it can not be add and also on a++ it tells me that i have to write it a += 1 and b-- it says b -= 1 i don't know i am confuse!

Thank you in advance

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It's not your fault! Swift deprecated the use of ++ and --. Switch the ++ to += 1 and the -- to -= 1. This should fix your errors. Hope this helps! :sparkles:

Thank you

swift 3 is a bit deferent ++ = ( += 1) and -- = ( -= 1)