Swift Fundamentals: Variables, Constants, and Types

Опубликовано: 20 Январь 2018
на канале: Cocoacasts
283
11

In the previous episode of Swift Fundamentals, we briefly talked about variables and constants. You learned that the var keyword declares a variable and the let keyword declares a constant. Variables and constants both store values that can be referenced by a name.

There's one key difference that we didn't discuss, though. The value stored in a constant cannot be changed. The compiler throws an error if you try to modify the value of a constant. Try it out.

https://cocoacasts.com/patterns