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!
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
I'm having difficulty understanding variable and constants
the video is too fasts
// Enter your code below
A variable is a label that can contain a value that you want to use again and again in your programs.
For example, instead of doing the following:
print("Hi, my name is Luke") print ("I am called Luke")
You can do this:
var name = Luke print ("Hi, my name is \(name)") print("I am called \(name)")
This way, you only have to change the value that is assigned to 'name' rather than changing the print statements output more than once.
The difference between variables and constants is pretty simple. One can be changed as it's a 'variable' value and the other is a 'constant' value so it cannot change and always remains the same.
I hope that this helped you out! If you need any more help then don't hesitate to ask.