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 Closures Closures in iOS Using a Closure

dexter foo
dexter foo
8,233 Points

why in a lot of Pasan's videos does he define something as a constant but says he's defining it as a variable?

I realised, in quite a number of his videos, when he says he is going to define something as a variable, he declares it as a let instead. Is there something that i missed out? Because it is really confusing me.

1 Answer

Enrique Munguía
Enrique Munguía
14,311 Points

I guess it is just a habit, when programming we think about variables all the time, that's how almost every programming language works, but in Swift there is a preference of let over var when you know that the value will never change. If you understand clearly the difference between those keywords you will do fine.

dexter foo
dexter foo
8,233 Points

Oh ok thanks that cleared my doubts!!