Variables

2 minutes
Share the link to this page
Copied
  Completed
Learn about the amazing data containers that are variables.

Transcript

Hello, and welcome to the third tutorial a swift basics series. And in this part we're going to be looking at variables, variables or storage locations for data within programming. The data can be manipulated and retrieved. variables in Swift are extremely easy, there is no need to specify the data type on like languages such as C and Objective C, if you use them, you'll know exactly what I'm talking about. And then use the keyword var to declare a variable be something like JavaScript, you'll feel right at home here with variables. So let's go ahead and open up our project.

You assign or you create a variable like this, you do var the name of variable and then you assign it a value and assign it a value nine. So this is an integer. When you assign a value, the variable becomes a certain data type. And if I were to do a equals 9.9, will give me an error because A is an integer but if I do equal eight is five with it because as an integer so you can only assign a certain type of value to a variable. Once it has a data type, we don't have to specify the datatype here, it automatically picks it up into var b equals 4.5. And this is a float value added var c equals true, this is a Boolean learning var d equals quotation marks hello world is a string value.

Well, that is that and we can use this any print line by saying print ln and you specify a variable at some specified T. If I run this, it says hello world changes to see on this it says consider true and if you run Be Your runner that this pop up disappear and it says 4.5 It's that simple. That's it for this tutorial. In the next tutorial we'll be looking at constants which are similar to variables but I think you can guess what the what what they are by the name. If you have any question feel free to message us at support at sono system Dakota UK email will be in the description. You can comment on this video or directly message us via YouTube. The source code for this tutorial will also be in the description for a link and as usual, thanks for watching and have a nice day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.