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 trialRoger Curiel
Courses Plus Student 58 PointsNeed help in variables
I really don't get it. Can you help me please!
1 Answer
Pedro RuÃz
28,105 PointsHi Roger, I'll do my best to help you out.
Think of a variable as a box where you will store a value (empty being a valid value for it.)
You use variables to store data and use it around your application. Using variables can help you save computing power as you can avoid having to recalculate values when you're going to use it several times. It can also be used to change the value of Labels, Images and other components in your User Interface.
There are different types of values that your variable can store. The type you choose for your variable will depend on what you want it to store. For example, the number 2 can be stored as an Int if you're going to be using it for mathematical operations, but can be stored as "2" in the form of a string if you're primarily going to use it as text. You can usually convert numbers stored as string into number formats (such as float or decimal.)
Apple has great documentation on the different kind of variable types and what they can be used for in case you want to dive further into it.
I hope this helps, and feel free to ask follow up questions!
Roger Curiel
Courses Plus Student 58 PointsThanks for your support!
Damien Watson
27,419 PointsDamien Watson
27,419 PointsHi Roger, what specifically don't you understand about variables?