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 trialbright adusei
Courses Plus Student 180 PointsI'm having difficulty understanding variable and constants
the video is too fasts
// Enter your code below
1 Answer
Luke Glazebrook
13,564 PointsHi Bright!
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.
-Luke
bright adusei
Courses Plus Student 180 Pointsbright adusei
Courses Plus Student 180 Pointsthank you Luke!
Luke Glazebrook
13,564 PointsLuke Glazebrook
13,564 PointsNo problem, glad I could help you out! Don't forget to mark a 'Best Answer' so other members of the Treehouse community know that your problem has been solved.