Swift Programming Basics : Learn to Code from Scratch [For Complete Beginners] | Shaping Edge | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Swift Programming Basics : Learn to Code from Scratch [For Complete Beginners]

teacher avatar Shaping Edge, iOS Developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (1h 58m)
    • 1. Introduction to Class

    • 2. Xcode Installation

    • 3. Playground in Xcode

    • 4. Variables and Constants

    • 5. Different Types of Operators in Swift

    • 6. Characters and Strings

    • 7. Collection Types in Swift

    • 8. Control Flow in Swift

    • 9. Functions in Swift

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Welcome to the Swift Programming Basics Class where we aim to start learning about Swift Programming from SCRATCH !!

Do you ever wanted to try out programming but didn't know where to begin? Want to learn Swift Programming so that you can create beautiful iPhone and iPad applications? You have come to the right place. Swift is a fast growing programming language for developing iOS, iPadOS, macOS, tvOS and watchOS applications. This class is designed for complete beginners who have no programming knowledge.

You don't need any past programming experience in any programming language to take this course, we will learn to Code Swift from Scratch. If you have a bit of programming background that's great, you'll catch up fast with Swift.

This Course Focuses on:

Use of Xcode's Playground Environment - Learn to use Playground which is very powerful Interactive work Environment for Swift Programming

Swift Variables and Constants - Learn the basics of Variables, Constants and their Data Types in Swift

Operators in Swift - Learn how to use various operators in Swift that includes Arithmetic Operators, Compound Assignment Operators, Comparison Operators and Logical Operators.

Characters and Strings - Learn to manipulate Strings and Characters in your code and different functions associated with them.

Collection Types in Swift - Learn about Arrays and Dictionaries in Swift and how to use them. Also learn about different properties associated with them.

Swift Control Flow - This section deals with iterators and conditionals. Learn to use while loops, repeat while loops and different For-in Loops in your Swift Programs.

Swift Functions - Finally, we will learn about Functions, how to create them, pass parameters to a function and get return values from a function.

By the end of this course, you will be well versed with:

  • Swift Fundamentals

  • Usability of Variables and Conditions in Swift

  • How to use Operators in Swift

  • Creating Functions & Different types of Loops

  • And you will be ready to create your first iOS App

To get the most out of this class, code along with me or after completing the video code by yourself and run your code to know how it works. If you get stuck anywhere, don't worry you can search for the errors online and I am sure you will find a solution. And I am always here to help you out.

So, what are you waiting for?

Get Started Right Now and Learn about Swift Programming!

Meet Your Teacher

Teacher Profile Image

Shaping Edge

iOS Developer



I'm an iOS Developer and like yourself an Apple Fan too. I started my journey in developing iOS apps for iPhones, iPads and Apple Watches a few years ago and now with my knowledge and experience, I intend to share it with others.

I believe the knowledge I share will not go in vain. My primary motive is to help others who are just starting to develop apps for iPhones and iPads, give them sufficient knowledge from Beginners to Intermediate level and from Intermediate to Advance so they can excel as an Apple Developer and be proud of themselves.

Feel free to reach out to me with any questions you have regarding my iOS Development Courses or any questions for that matter.

Happy Coding! :)

See full profile

Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction to Class: do you want to create? Guess iPhone application, but don't know where to begin. Do you know the average salary? Often Iris developer is $125,000 for you on with experience, it can go all the way up to $212,000. Or you do you know, by the end of 2090 the absolute is going to hit $99 billion that's with a B in 2000 and 14 have been released. Its with programming language for developing applications for IOS, hyper, Doha's micro esteve us and even war choice. If you have no programming experience at all that this course is just for you. Swift is an evergreen programming language, and we're going to start learning by downloading export, which is the required to begin with 50. Then I'm going to explain you what are variables and constants from there. We're gonna go see how we use different operators, and we will also learn about characters and strings, and after which we will learn about collection types and control flow. In the end, we will be seeing how to create functions and play with them at the end. All I want from you is your computer tension and motivation to loans to get more start of scores, court along with me and play around with the cool you create. If you're ready to learn swift, then I'm here to help you so get started right now and learn about basics off swift programming. 2. Xcode Installation: let's begin by downloading the tools we need to learn swift programming. So for starting with Swift, we need to install X Scored, which is the apples official, integrated development environment or also called society. It is used to build iPhone and iPad applications using swift programming language. So head onto the F stone. You, MacBook just search for Xcor. And the first result you will see is off X court, which is the developer tools. Just go ahead and download it from right here. I'm not updating it because it is a big file, so just download it and it is off 7 to 8 gv, so it is going to take some time to download. Then when it's downloader, just open up X scored. So this is your welcome screen. You're you can start with a playground or creating a good project or Cloonan existing project. You can even open any project that you downloaded from the Internet. So in the next video, we're going to start with playground 3. Playground in Xcode: Let's begin learnings with programming using playground, which is an attractive work environment that allow us to see the results of the Swift Corvair return immediately on the right side. Well, it seems so select. Get started with the playground. You can select the platform. I'm going to select my quest for now on create a blank file. Next. Then I had the name. Do it on. Select that. Stop wherever you want to place the file My pit, my playground. It will create a file. My playground. A playground. So this is where you have to court in Swift. And this is the right side where the result off that good will appeal. You can select an environment is automatic. So whenever we write something whenever we were let's say friend. Hello. So it is going to immediately run the court and print output right here. As you can see, it does showing the result off the string. Hello. Playground and the Prince statement also right now are down Right here is the console which everything you print is going to print in the console. And if there is any air in the court, it will show in the console itself. So this is where this is the part in where you can select manual rent or automatic rand, and this is the console where the Prince statement and errors will be shown. So let's clear out this and let's begin learning skirt from scratch. The first thing you should learn any programming languages how to make a comment. So when we write the court, you want to comment that you want to make the document documentation off the court, that this particular court does this. So let's if I add two plus three and I don't don't say that this particular line says addition, off two on three. So the court compiler just runs this particular part and takes this as a comment. So in order to put a comment you have to put forward slash and then you can write anything and it will be a common. And if you want, like multiple line of lines of comments, then you go forward, slash star on inside. You can write anything, and then, in order to close the comment, you have to again put star and forward slash It's invoice off this, and after that, whatever you write will be taken. ISS Gordon, Sift on it will print right here. Look. And the value of two plus trees fight. All right, so you know the basics off playground Now, we're going to start with really a built in our next radio. 4. Variables and Constants: in this video, we're going to learn about variables and constants in Swift. So let's me just full screen this, All right, so we're tables are the ones using which restore information in a program. They're very similar to the variable to my tester. Didn't new math class or value their restored with the name been really Clara Variable the phone computer. Any other system, for that matter, will set some off its ram aside toe. Hold the value of that variable. We give variable, distinct name so that we don't need to use point those on my merry addresses. We can just give the name off variables, as that's why equal to 30 oh are name. It will do John Variables a mutable so that their values can be changed with the court at any point in time in a program. On the other hand, constants. I am mutable. Their value cannot be changed once there's defined, they have their fixed value, and no, for the modifications can be done to its value in swift Re declare a variable using the Cheever bar. So let's put a what is the keeper, then follows the name off that we're able so str then unequal toe and then you can write the value of the reliable that you want to assign. So let's say hello Leg around Andi men, it is automatically run. You can see the value off. Hello. Playground is said to the variable var str Now let's see how we can define and define a constant So the constant uses the keyword lead. So let let by equals two you know the value of by 3.1415 do Oh yeah just 9 to 6. All right, so the value of y is a constant It cannot change right? So we set up set it as a constant so it cannot be more different in the future. So this is the value and it is stored under the constant by this declaration is used for constant whose value we can't change or reassigning our program There is little difference how one was a variable str on another one was over the similar number that despite we don't need to express it retails with the type off Really able redefined However, we can explicitly declare a variable with a specific type as we want the value off the variable toe have. So in order to do that, we can just right. You are Onda number and we warned this number to be an individual. So we write jokey were end of it, the colon and then equal. Then you can only write in InVision number so we can write well or 1 25 are you and zero even a negative number. But we cannot ever put or the similar to word or we cannot, oh, add a string third so it will give another cannot convert the value off type double to end , so we have to keep it as an individual itself. So we have forced on variable to be an individual. Now let's talk about readable types and interfaces and swift were many different types of data types. We'll look at the most common mints. The 1st 1 is an individual, which is a positive or the negative whole numbers without any decimal point. Indigenous can be signed for the tour negative or zero, or they can be unsigned, only positive or zero. We didn't really know those signed in digital by the type and and an unsigned int digit by the type U. N So as you can see, this is an end. And if you want a u. N, you just every right you end, I will keep it as end. Both of these values are not your mathematical anti jurors as their upper bound and low about since the computers, other systems memories limited so we can get an upper bound or lower bound by typing and Max are intimate in our playgrounds, So we'll do brain me on individual maximum. So this is the maximum number you can see down in the console. This is the maximum value often did. Indeed, you can take on the same way you can write end men see? All right, so we'll just move this now. Swift also is a data type for real numbers on numbers with decimal points. They're called this floating point numbers. This index is named as float end. Edible will be using double, most often because it is the most popular one and the most used data type four decimal points. So we can say what age is equal to 21 which is in India, then what height which may nor be in in digital. So we want high to be 5.85 point eight. So it is a double. No. If you just click on option Andi click so you can see the declaration to our height is irritable so but it's an option. And click on height, you can do the same for option height and age resentment Video. Now, if we want to add Oh, an indigent inner double registered reservoir X equals two. Let it 34 plus 52.9, so it will run it and we'll give you the value off it. Swift will assume that the the type to be an end as the number with a decimal point and height, which has or decimal no swift will assume this to be an indigent because it does not ever decimal. And this to be a double because it hasn't decimal point. Now, when we add in, indigenous double will get a double itself right. So if he old and click a dessert double now, we can also another dated. I've called this bullion, which holds the values whether true bullion towards the value s either true or falls, so we can declare bullion the same ever declare any other variable. We just have to survive, um, beside to the very limits. Decide Andi, if you want, we can initialize it as their data type, or we can keep it as this so will force it to be a bullion, and it will be true so it can take the value true or falls. We will see more off this bullion way table when we talk about control flu, because 1,000,000,000 will be used most often there. Now let's talk about type conversions. We all know swift in for the type off, some off an anti jer and the real number. But if you want to get an individual, some office into gender double, we wanted to be an individual only so surfed. Allow us to do that convert between indigenous and floating point values in a very easy way . We simply need to write the type and have a set off. Parentis is, and the value inside the parent is this will be converted to the type return outside. So we just have to say, Let's say, let I'm involved. We want end X. I mean individual off the value eggs. We deserved a sit in and then in the parent Israel. Right X. So it will convert this double doing. Indeed, you right now, if you notice the value is 86.90001 so it does not round off, but it just removes the decimal. And though for the part off it this because converting a floating point numbers under. Indeed, you're drunk kids there decimal part and it does not round off the value. Getting me great. Now let's talk about optionals. So let's say we have. We had a user to enter a string value and we want to convert it to an individual. Let's go. Simple example. Let's see the world number in string. So the user's went excuses. Value is 23 57 This is the number the user imports partisan string. Right? So if you want to convert it to in teacher, we just right. What number in t. J. This is the variable name, then rejiggered as an optional end Grishin MMA equals to end. And inside this brackets free right number and strength. So, you know, we can convert the number 2357 20 Joe pretty easily, but not Hello. Oh, I mean, if we want to convert this to an individual, we cannot convert it because it is a string. Swift has an easy way to handle this type of conversions on through the structure called optionals an optional say. Either that a specific value, the specific value exist. And it is this an individual and it is this or that does not that value does not exist. You're We can convert the number 2357 to 1 and did a pretty easily. But if we pass str it cannot convert that toe an individual past str so it will take that is it and indeed you it will result in it. So it is not an individual hands. It won't store anything in this variable to declare an optional We need to explicitly declared the data type and put a question mark like this. Suppose we are given an optional to print out, but you don't know if it has a value or not. If this if it has, then we won't want to force. We have to print that value. This is called fools. Fourth unwrapping. Let's see an example. So let's say if number in string number and end number. And indeed, Joe is not equal to nil, so it has some value. Then we want to print that number. This will print the number or 2357 as an optional. Never. If we want to remove the optional, we just have to put an exclamation after the optional value, so it will print out the number 2357 We will talk about if statements later in control flow section. But for now, you just know that the if statement is checking whether or not there is a value in the optional variable. If that is, then it is sprinting that we just can't bring the value if it if it is an optional. That's why we have the fourth. Unwrap it by putting an exclamation right there. There's another way we can apply this scenario. Calder's optional binding in this technique. We buying the value off the optional to constant If the value exists and it is not nil. Let's see if let gonna work did Number is equal toe end off number and strength, and we print it out. You bring the converted number and it's we friend no value sword will convert the number and string to an anti Asia on. If let the world what a flat does is it will check if this value exists. That means the individual is going. The string is converted to an anti Joe, and it has some value. Then only it will pass if a true statement. So if if this is true, that means it has a value. Then we'll go inside the block off if and will print the converter number. If it is false, that means the number cannot be converted to an anti Joe, and this value stays nil. Then it will print no value. This way we can use optional binding to bind the value off that optional to a constant so we can use it later. All right, that's it for this video off variables and constants. In the next video, I'll talk about characters and strings 5. Different Types of Operators in Swift: all right, so in this lesson, we will learn about how to use operators and swift. So just open a pack school, create a new playground under my CO a selective blank document and just name it. Operators on DSI would whatever you want to keep that stop and he ordered, opens up suggestive of everything. And let's begin with swift operators. So they're basically a few types of for potatoes will start off by the most simplest one, which is called this assignment operator. Assignment off right off now is the most basic one. It just assigns a value to obey able. So let's say you are a is equal to 23. So this equal do is an assignment operator as simple as that. So it assigns the value of 23 to the reliable E. So whenever we set a door to my take, it's automatic. It's running and the value off he will be 23. All right, so we can also save Variable Name is equal toe. Josh hopes Josh, so we will assign the value George to the variable name Simple right the next to operate over talk about this arithmetic operator arithmetic Alfredo on it. It contains so sorting operators like you might have seen me in maths class Bless minus multiplication division. And there's also one more protocol s more Euless, which is defined by person Date sign. So what model is does this? When we divide two numbers, it will give the remainder offered. So ignore this. No. Let's start with the additional print edition operator. We can add two numbers or even strings. We can you win air strings called getting it to strings service. Edouard, Hello is equal. Do Hello, then space. Then we can use additional operator additional printer and their two strings. Combine it and save it to Hello. So hello league around, it will concrete in it both the strings and started and hello? No, we can also add two numbers So some is equal toe 3rd 10 plus 30 One of them could even be in our decimal point So it really story doesn't double? No, we'll talk about multiplication division. I'm in subtraction, multiplication division and more realist. So we'll just take two numbers. See, it was too many on variable Q equals Do five. So if you want to stop back to numbers We'll just use pre minus que week anyone assign it to something or if you just sit p minus you, then it will subtract and give the value. Next be multiplayer. Thank you. So guess what? Everything. What will it be? 100 on? Be derided by Q so 20 divided by 54 Correct on. Next thing we'll talk about it. More release operator. What more release operator does is it will divide, be bike you on it will give the it will return the remainder off their division. So when did write it by five? The question is four, but they're amendable before If I change it to 19. So 35 15 16 17 18 19 4 is the remainder. All right, Just change it back to Grandi is the more realist operator the next operative will talk about is compound assignment off radar Come phone assignment. So you you might have seen if you want to add bien que and store it and be we would have used something like equals to be Klasky, right? And the value of me will be updated toe 25 you see? No. If you can use compound assignment by using plus equals come together so well. Sippy plus equals Q so it will take me Add it took you on Started in pizzas The next operator which you talk about this comparison operator Comparison operator. Now there are a few type of comparison Operators will start off by the most simplest one, which is equality. So let the let's different on other things Variable are that's different Variables are equals Dio I already do and read it Brother s equals two No, we'll start off by equality operator so we can just type are in trouble equals s so we'll check whether r is equal to or equal to s are not so This is the equality operator double equals quality operate Oh, check and Redon whether it's true or false. So if I say s is also 32 then will return to getting me the next Alberto is greater than so our is greater than IHS greater than operator So it's also true because 32 is greater than 12 right on next Operator is are less than s which is less than operator which is false then next operators are greater than equal toe s the next operators are less than equal to west, so it is less than quick these other basic or produce you might have started in mats. So are is 32 SS. Trail R is equal toe. 32 is equal. Goodwill Falls 32 is greater than, well, true. Produced less than, well, false 32 is greater than equal. Two through 32 is less than it will do. Falls. Getting me all right. The next operative, which we talk about is nearly operator Dorner Rio Preto. So what? It does this If I have a statement, uh, let's A variable number is equal to 67 on the parity offered. It's there to 68 a parity Barrett is either it is even or are so currently will say it is none. And if you check parity, how can reject parody sober? Divide the number by two, and if the remainder is zero, then it is an even number, correct. So we'll use a more realist operator for this, so we'll divide the number if number more or less to is equal to zero. Don't worry, if you're not understanding this a flu, if conditions, we'll talk about it later on. So if a number divided by two leaves the remainder as zero, which is equal to zero for, is equal to zero, then parity is even then the number is even. It is if the number divided by two is not equal to zero. I mean, if it is equal to zero, it will run this part off court. And if it is not equal to zero, then it will go to next else. So you're parity becomes or correct. All right, now this is a let's just bring clarity. So when a transit prince parity years even so, 68 is even if I right 34 between 33 it's are so it will write our every print out. Are we want and dire this the best part about the ordinary operators? It removes this number off lines off course, fire lines off core on most. So what Tony operator does is it doesn't end single line. So it is. Parity is equal. Do number more journalists to equal to equal to zero, then put space and it put a question mark and then, if it is true, then fill print everything on this side off the Golan. And if it is false, then we'll assigned the value of parity off everything this side of the court decide. So we'll say it is even on will say you. It is our So when number divided by two more real is 20 then we assigned parity is even. And if it is false, then after the then everything off after the semi colon is taken getting me the serpent or the same value as this parent, the about of state mended. All right. It squishes down the F condition so that was stored near the operator. The next operate. Next thing we talk about, this ranges. So if we want to, let's say, take values from 1 200 we won't be typing it Trump. And 200 right? So we'll use for look for that while using for loop. If I want the numbers from 1 200 use for Look, I in no, we use range acea, so we want the hydration off this for look, Toby from one dot dot 1.0.100 On a minute I treat from 1 200 will assign that value. Do I So, basically, this is a range from 1 200 including 100. So we'll print out I So it will. I trade from gun 2234 of all the way up to 100 including 100. All right, so you you can see it does I created on the way from 1 200 Now, if you want this range to be from 1 200 but excluding 100 then we used the less than operator wonder dot less than 100. Then it will print print out of 99. Yes, Dr 99. These are ranges. The next thing we talk about is logical or potatoes, which includes basically three types of logical operators, not not defined by an exclamation mark and which is defined by double, um, persons and O R, which is defined by two straight lines. You can use this lines very press holding down shift on the back slash ero backs back slash p and you'll get this lines. Now let's talk what this operators, the operators do not operators simply negates the value. So if the value is true, it will make it falls. And if it is false, it will make it through on what and operator does is it will take the condition off the opens off only decides off and operator. And if both of them, if this and this both of them are true, then only it and dialled and wilder tone through. If you don't one of them are false, then will return falls all right. Same way or operate in a totally different way or a printer does. Is if either one of them is true, then it will return proof. If both of them are false, then only Winterton folds. All right, so let's see this in action. So we'll take a very able have email. I will use the example often email password. Having real equals two falls if I don't have an email, but I have a password offered, so it is silly, but you have a password. If it is true, that means I have password, but I don't have any meal. So in that case, what we'll do is use a if statement if have a password or I mean and must be real and have password. If a person has both off these, if this is true, they have an email and they have a password then only they can be granted access to it exist. Granted. So let me We just right it's friend access denied. So if they haven't email address and they have a password offered, then only they can be granted access. If they're an email but don't have the passport off if their pastor but don't have the email then the access one big under understanding this was simple and operator so and warns through on either sides then only it will return true and go inside the estate if block All right next example will talk about or and not together. So let's say what door loved is the door law true? That means it is locked. What have keys? Do you have the keys? Faults So the door is love but I don't have the keys. So access when we counted Correct? No, If I see if not Door loved are Oops. Have Geest then friend exist granted to in tow It's door remains shut. So are doing The door remains closed. So what? This does this? It will take the door lock if their door look is I mean the door is locked. That means this part door lock becomes true. The door is locked and not sure Look becomes false because do longest true and not becomes false. So this entire part is false. If the door is true, the door is locked. Then this entire part becomes false if false or have keys. If have keys is true and the door is locked, then only access is granted to enter. So just think about it for a minute. The door look do Islam. That means this is true But including not it becomes false. No, When the door is locked you can't get access if you don't have the keys So this entire part becomes false and using. Or you should have the keys. Trento Correct. So there's another example. Oh, almost similar to this one, right? If you have the keys and the door is locked, then only you can get access Now If door is not love. If this door law is false, there is not long. Then this becomes true, right? So it doesn't matter if this is false or true. The door is unlocked. Then you can anyways enter the room, right? Yeah, on the next thing is we'll combine them. Combine this logical operators and to create a complex the statement. So combining them reduce if this understand it properly. It's simple door, log, cabin, door long and have keys or no door love. So, uh, this is the part this the combined statement. So if do is not door is not locked then onto in Canada doesn't Monday fifties or not? And this is the expansion format off this, so you can say door lock and keys. If they have both, then this back part becomes true and it doesn't matter. Whatever it is after our so it can be true or false, it doesn't matter with anyone. Still give access on def, the some. If anyone off them is true, then this and I apart becomes false and or now depends of the door is locked or not. If the door is not locked, so this becomes true and it is our so it will entire part will become true enemies, right? So it will give access to the members of news entry. So let's make some changes and play around with it. So door is locked true and have kisses false. So door remains closed because we don't have the keys. If he said it was true, that means the doors on law and we have the keys. So this will also become true and access is granted in either of the case. No, if their daughters not log and we have keys or doesn't have, it doesn't matter. It will still grant access to the man, whoever's entering the door, right? But that was it for producing Swift hope. You on the student properly on, and in the next video, we'll learn about characters and strings and swift. 6. Characters and Strings: in this video, we're going to learn about characters and string and swift. So open it back scored. This is your old project, my playground. We create a new playground project. Get seconded League Atone Blank document. Then let's name it strings and character does on and say we didn't best off Whatever you want, just full screen it this on. Let's start with characters and strings force. We will look into a string data dive, which is which is a sequence of characters. These characters can be anything an individual or number for decimal number words, symbols, special characters, etcetera, anything sensitive. The sequence of characters. It is named this string so we can have a string to be a constant or variable but enclosed by the by codes so we can say we wanted to be available. And my string is the name of that really able and in double quotes, you can type your string. I know I would. On DIT is set to automatic. You can see right your shoes for creating an empty string. We can either use consecutive double courts like the string. We can just used consecutive double courts that makes it empty or we can use swift initialize is syntax, so we can check if the string is empty by using the property. If empty is empty, which we call of which men called returns a Boolean value. Either true that say's the string is empty or false There. This string is not empty so we can check over like this. So that's a lot b str we talked to. It's equal to string, which also create an empty string. No, we save our yes to your and empty. This is the name of the string name off the variable, and we wanted to be a boon and will use the property off string Dot is empty, so we'll check of the string is empty or not, and if it is empty, it will return through. And if it jay my string, it will be falls because it was filled. It is not an M d string. All right, so now let's talk about string mutability strings when, when defined as we're neighbours or bar, but not a constant. When defined as variables, they can be altered, muted or mortified. We can use the additional operator as a string concatenation, so that's mutability Onda. We can use a recent operator as the string concrete concrete Intentional pretty If we can use compound additional additional Peredo so we can save our e Is is the f or let's say hello and what B is John. Now we're going to combine this. We just type a les B. It will call in Coordinated It will add it on it will print. Hello, John. It will show Hello, John, on the right thing. Now, as you can see, I left a space, right? You said hello and John does not come by Does not go on carrying it together because it will can get in it A and B without any spaces So way have to make sure that we put the space in those string itself No, let's use Compound Edition and let's see how it works Minutes of our complete string So now let's use compound additional Operator which is sooner a just bless equal Toby So it will add be to itself But with so it is as seamers 30 that Seamus equals two a plus b This is the same as this so it will RB to itself and student in a and it will show. Hello, John. No, let's talk about string interpolation in, uh, relation. So what? We want to insert a numerical value into general double into a string we can you strings spring interpolation to directly insert or the variables into a string began Or do this by inserting other be able anywhere No double inside edible coats. So let's have our my favorite number and we initialize it s string. Let's also put a string right here. Initialize it a string my favorite number is. And if you want to add an indigent inside this, we just have to put backslash and round brackets. And inside this weirdo writer in digital began right 32 or 3 25 or you can even right, oh, available. So let's save our no music will Doe 79 and my food it number is number and it will earn 79 in place off this you're my favorite number is 79 so we can on multiple Ah, this type of interpolation. Let's see what marks is a will to 114.0 and let out off marks is equal to 1 40 0.0. So we'll see. Oh grand, you want MOX is marks on and out off. I loved off and we can even have some money to make some calculations inside a string. This way percentage is marks my divide by 100 on divided by out off. So this will calculate this value, Andi added. Inside the string and printed out for us, it even 0.42% is DOMA is the value of that. Are is the result off that calculation, So we have initialized. So this way we can write variables, names or even expressions like this inside a string with round brackets, which is followed by O forwards Back slash to insert values off any other data type inside a string. Now let's talk about characters. No, Garrick does so as we knew from string definition that strings are made up of characters on . We can get access to all of the characters off a string to count them, using the character property count. So we said, let greeting is equal. Do hello on and we want to print the number of characters in this greeting variable. So visit a friend. We heard off our greeting as grating dark count using this function. Oh, get it does. If you convert the string and count every oh Garrick turns our district, it has five getting those getting Lee. Let's see, uh uh, Let's get individual characters. So in the visual, Garrick does off that greeting select greed. Let's convert that string into a character every so that every character is placed in an area greeting. Get it? Does Eddie And we converted by saying, We write airy on drowned brackets. Weird greeting the strength. No, it will go on board the greeting string in tow. Character areas characterised. So now we friend No greeting Director Eddie, and we'll see what it looks like. So this is the character area, and we want to access only one off the element. Then we just put a square bracket after character Harry and write the index value so you can see right here. This is in big zero. It starts from index zero. All the areas and most off the programming languages starts from 00 indexed. So this is zero index is one index 234 If you put zero index in the square brackets, then we take the airy and print out the zeroth position value. So it is edge if you put one. So now if you want to print all the characters and each line so we just write a for loop Don't very well learn about four loops later on for in the visual. Yeah, addictive. In greeting Garrick that Eddie and we bring that individual director print individual Correcto. So just remove this so it will print edge e l l o getting me. Oh, in the second line, off course we take the total count or the number of characters in the string greeting whose value is Hello? So in this for love just understand that individual character will take value off each element off this Harry. And it will hydrated continuously until although elements off finished so it will take edge . It will I trade. It will print that edge that it will take this next character which is e than l then. Oh, then double and then Oh, and when all the characters characters are over, then this four look is ended and the control is set to the next line. Like right here. So now let's talk about mortifying get a closing string, mortifying characters and string. This is a very simple matter using the function Golders replace Replacing occurance is so Let's Ivar Ward is meet and we want to convert it to meet MGE ability. So we use the word you assigned the world with word. Don't replace occurrences. All right, it's replace Occurance is a function that we won't we need to import from Foundations Import Foundation and some of the functions will be included in this foundation. So we have to write import foundation now if the right word dot replace or Curren's Yeah, I just went on. Yeah, replace all occurences off. We want off. We want to replace it with in So the world updated value off world will become subjective value of the world will become meat from M double M u T to end ability. Her dysfunction will replace a with a character with character e. You can have multiple strings, so m e. If you want to replace it with I so it would become m I. D. Look. All right, let's talk about let's talk a word. String comparisons. Well, if you want. If you have two strings, let's Ivar even is here, there. And you want to compare it with wire A do? There it is. Oops. Hello there. Now both the strings are not equal. Of course we know word so we can just see a one is equal. Do a tow here to put double equals to in order to check equality off a string so it will print out falls because it is not equal, Right? Just went on. No kids falls. Now if we change here Hello, do. Hey, then it will print out us. True, because everyone is equal to two is equal to a toe. See? All right, that is the end off strings. And Constance, I hope you understand. And, God meaningful values our effort. Next, people talk about collection types and swift. 7. Collection Types in Swift: In this video, we learn about collection types and swift. So have poured three main collection types. A raise sets in dictionaries, a recently nearly ordered buying index starting from zero sets, content on order, unique values and dictionary store and a new order collection off key value. Pez. We'll talk more about a reason dictionaries in this video, because they are the most popularly used, with no doubt about sets. So it is in the in the stable. Oh, shows an area of its consist of grocery items, essentially a raise. Our order list off elements off the same type where each element is linked to a set off in that index indexes, even if in a raise empty, it can hold values off a particular later type. In addition to this, it is very important to know that swift areas are zero index that witnessed. That means it starts from zero on it. Will I trade from two from 0 to 1 toe treat to pull that weight, fields and area. So let's understand this. With an example. Open a big score playground blank negron and name it collection type production types and sued whether you want to stop. Let's make it full screen. You wrote this, Andi. So we'll take Example is variable. We'll initialize an empty area. Empty arrays it will do. It is a string, Gaby, and it's empty. The next wavy aleck Spinelli destroyed taipan. Dive down the court and explain you everything so far zeros and repeat repeating from zero to con 20. Then we just take the cone. Dorial explain that we just type it down. Rod. Grocery list eggs putting Just good. Fresh. Make a net over you and numbers do Full 68 Okay. All right. So in this score, you're going to the first line. Sure creates an empty area. Begin initialize an area off any data type, or you're being utilized this string. You can do it for integer double or even Boolean stripped all talking with the capability to pre populated area with the repeating value, as shown your so will repeat. Zero. Still the countess 20. So when we run this said to door to medical and so very running on indigent arrays initialized on with the name is zero and 20 number of zeros are added. You can see right here that 20 number of zeros on the zeros. Airy counters. 20. So there 20 elements with the value zero each having zero each year. So all areas have account property. This come property. Every area hasn't count property. And if you want to pre populate in A with some values, we can declare variable and create a comma separated inside a square bracket so we can add , Oh, extra items. Let's say we also warned, Dude Based All right, we can add it. This is a freedom pre populated at Revere to order to define it and grossly grocery list areas off is a string. Gary, you can just gonna select an option and click grocery list. You can see to string Gary and zeros represented Digit, Eddie. And this is an empty string, Gary. And this is indigent. Ready? All right, swift over ill used or type in the interference due to mind the type off an area like in this line, it was determined that it isn't in digital. Harry, in the senator's reminder dissents string Eddie. All right, so we can do to my culinary is empty or not by using the ISS empty property. So if we want to check If this area is empty on on, then we'll use empty. Every dot is empty. Are you sure through that it is empty or false if it is not empty, so grocery list will come as false? All right, great. No. When we declare in areas variable, that means the area becomes prone to change like this on our becomes muted. But after they have been inst enshi ated. So they do that two different ways to upend an airy by using over append so grocery list not upend. You're very new element to this area. We also warned, Let's see, had a fresh so it will upend that toe the grocery list and we can print the grocery list. It will also include hair brush. All right, no adobe weaken. A pendant area is by using compound addition operator like this on early video. So grocery list plus equals two. Yeah, use of square brackets and inside this well, right buying EPA's and then if I print grocery list, certain will also include pineapple this world so we can upend in an area. So now, if we want to push an element at a specific index in an area we do that using the insert function so values you can see this is the current grocery every right. So we'll use grocery dot insert and the new element. Let it be Berekum border, and we won't do in sort of that. That's a second position. So this is forced. This is this is the right position. This is forced, then come second. So after milk that compartment powder is added and then oranges so you can see this is zero . This is one. This is two, so it is added employees at place to so in place of oranges. It is a retail compound, er, powder and everything. Rest will be shifted toe right. So after Telkom bottoms are induced toothbrush, toothpaste and hair brush and then pineapples, you can see all right, so this is the way you can insert an element at a particular position. This also shows that Eddie R. Zero index on the first element begins with zero and becomes begins with index zero. Now let's retrieve and update their data in an area using this in Texas. So let's see. But second item music will do grocery list on one because it is zero index. Right, So the second item will be You can see it right here. Look. Second vitamins milk so exist for certain. Within leg zero, this is secondary template Index one. So this is the second night time which we have taking and storing it in second item variable. No, let's if we wound 1st 3 items So what we'll do is will take grocery list and in the square brackets will start from zero, then dot dot to 701 end to all of the three items on student Didn't Oh, sorry. Triple dots and started in the 4th 3 items. You can see eggs, milk and tell compote. This added. Now, if you want to remove an element, we can remove it and die libre using the falling matter. The return value is the element that was reboot, but we don't have to you. We don't have to use the return value, so we'll see a grocery list. Don't remove at index Ed do and will remove underdone there. Removed item. It will remove them, taken border and return that item. Now if you bring the grocery list, all that comes with it, except for telecom border you can see begin store who are remove items and it was stored. I comported in this removed item. All right, great. So it is important to note that the reward off any item from the middle off an area will close up any off the gaps in the middle. So and this will come forward in those second position second index. This will be the third index. This will be the fourth index. This will be the 15 Dexter sliver, the 60 index order. So we can I dread in every in two different ways, either by element or by index and element. So we will use four loops to explain it in detail. Well, I understand. For loops in control flow, Section two don't worry about it. So that's if for each element so it will take each element from the grocery list. So in every iteration, the limiting the grocery list ISS set to eat element. Now if your friend each element, then you look that the force certain the grocery list insecto each element, then it goes in third prints and then I treats again. The second item is taken and stored in each element, then third items taken from grocery list and added to each element. And then it brings all right your understanding. The four look no good. So no there seven items and it has printed all the seven items. So this way you can retrieve all the elements off an airy. And that's also another way Vitor talked about that. Is this waas just by elements in our this index violent index and elements? So four we'll take a pupil index coma element and from grocery list not in numerator, so it will return the valuing in a few performance. So index with index an element in the value of that element. So it will return index an element, and we'll print it out the indexes and it's value off that value in that particular indexes the element, All right, so you can see their index value in this Prince Street wind. So in the 2nd 4 Loop and UMA rated function undertones there to pull off ENCOM A C where n is the index and see is the element in the value of the element. So since then, indexing starts with zero in the printer 20 year index, plus one so We can just say position and regret index plus one for no, but off the item and reprint. So it starts from's indexes. He starts from zero, but in the explosion becomes one for the foresight and number of items. One value is eggs. Number of the item is too. And the value is milk on that. The number of the item is seven. And despite up the values pineapple. All right, great. So now we talk about dictionaries, disclosed this a dictionary, stools, a key value pairs. All of the keys have to be the same day off. Same daily life and off. All of the values must must be of the same data type. There is no compulsion that the keys and values must be of the same deter type. Each key must be unique and has to be associated with value. We cannot have two same keys. And also one key cannot be mapped to two different values. When he cannot have two different values on, we cannot have two same type of keys we cannot ever ready and ready. We're gonna live. Ready? All right. So the key value pair me 1,000,000 dictionary aren't in any specific order. Let's see how we can create a dictionary. So Big Suri in the Savard student dignity will create an empty dictionary and on and in string. So indigenous, the key and string is the value and were created an empty area. I'm dictionary Saudi, So let's a student. We won't. Those student number you live in to be to have the name John and lets a student 79. I have done a bird dropped. All right, so now we'll print and I student dictionary. It is sure that it has to value key value. Pass one is 11 is the key, and join is the value. This is the key, and this is the value. All right, now in oh, in the next line. If you want to clear the anti a dictionary, well, just you are student colon between the square records or student equals two square brackets in the colon. In between, right, it will again make their dicks Terry empty. So now let's see how we can pre populate this dictionary so we can save our neighbors neighbors. One let's see is a key value pair often Inti Joe into those Dickie on a string is the value . This is the key value pair and let's be populated to with Goodwin. The three days Mr Holmes on and in 29 stays Dr No Good. And that's in neighbors, too. We have again in the same key value passport. Be honored. Oh, initializing it has one because Swift interpreter it automatically interpret what type of key value Peritus world data type is. It is. So we'll be to 23. This will be seen, Mr Etch, let's see. And don't really nine And this Dr Dani So you can see right your it will initialize it and said the values off neighbors Wonder neighbor, too. The only difference between these two numbers is this to initialization off dictionaries is Oh, we in the first line, we have defined their diaper off key value pair while in the second line, those interpreters automatically interpreted what type of data we have given to him. So if you just option and like this, we can say we can see this individual and string key value pass. So, like we used indexes and airy, you're in order to exist the value in a dictionary. We will use keys we can retreat, you update or create elements using those subscript notation. Let's look at an example. So let's stay stocks is he will do athe else dogs out off apple at the company, then GOOG are for Rubio company on will use beatable. Don't Bunny is equal to stocks on Well, we want only 11 of the companies and will write the this key to it and will retrieve the value of their company. I mean, the name of the company. So if you want the Google company, we just ride the key. That is good. And it will return those talk or it in the name of the company whose stock is group. It was with distorted and company. All right, so now if you want to update a value in this particular dictionary, so we'll just use stock on will use the key, which is a pl. And we warned the Apple stock name. I mean, the AP Istok, we have the company name is apple ink Nordeste app it, but it'll be about later that you can see it in the stocks. Yeah, so at a police convoy has been changed to appealing the same way we can do it for Facebook , Let's say of evil enemy element to that stocks dictionary. All right, so it's a every B is equal. Do Facebook. Where does it added a new element to their dictionary. So now, since dictionary consists off two sets off values, there are three ways we can. I'd rate over a dictionary key value pairs, just keys and just best. So this is what we can do that so well say four key. Come on, value in stocks and just friended friend Key Andi value to be, well, you so it will print out the key and value per the keys. Every group MSFT and a PPL. And the values are the name of the company Facebook, Google, Microsoft and Apple. Right? The next thing we can do is be under a tree with the keys. So for that we can do for he's in stocks on dot Keys sold will take all the keys and return it toe this value singles in the keys it in iteration so we can just print out keys. I mean, just he's and friend here oil keys and you can do the same for oh values dot values. I just met you. It's just name. So depend out all keys and all values. This will print all the peace we have taken on stocks Darkies Only the keys off the dictionary and this part we're going to take undervalues after dictionary So different all the keys on all the values separately. All right, this is how you can retrieve. Oh, values this Three different types off keys only value Dickies and developer. And I keep caliper. All right, so last time we will see how we can get all the keys and values separately. Offer dictionary and save it in an area. So let's let all keys is equal. Do string citizen string Gary Or will take all the keys and started in an area stringer It says so. Stocks darkies the same level. Do it for every let all value is equal to it will be in string. Gary, It is all the name of all the names of the companies, right? Stocks, dark values. Did you take all the keys and started in a string? Gary under the well in the name, all keys and all values will be the variable containing all the string area off the values so you can see right here. All these are just keys on and all the values that stood in all values. There's one moving on to talk about and that's multi diamond stone area. We just go up there. All right, my B diverged lady. So what? This ad it does is it has added insert if it Eddie. So let's see Rondo multi dimensional area. Andi. It's do type is defined as square brackets in sort of a square brackets. And inside that you have been ordered to your type. So and this makes it this entire part makes it a murder. Dem instant, Eddie. No, I can see I want an Eddie in sort of the area I want under the A with three elements and I went on a diary off the primary Harry 456 Then I won't 789 So what this has done is it has created in my deny, Mr Area. My theory on the entire area consists of three elements Go forced element, the second element and the third element. And that individual element is an area itself, and it has values, or it has elements. 123456 and 789 in the tour area. So, in order to exist in my damaging that every district great money theory. And if we won't let see those second in a second and die ready. So the right one because of disease or index. So it returns those second element off there, Terry, those the first index element? No, every phone. An element off. Better an element from that area. We just heard this. So Adam and those square square brackets and see, we won't zero position. So it will take for all right now we want to update that area so we won't go second position. Oh, I mean, then next to Eddie. And in that Eddie I want, though First position to be changed to 88 rather than eight. No, let's see what Manti Eric consists off. So it really going to 34567 Double eight 88 Ben, nine that you can abate in and murdered. I'm Instant Addy. So there was everything you need to know for collection types and swift. We learned about ah, Aires and dictionaries and in the next reopen, learn about control flu, which will contain, if statements, if else statements else if statements which cases four loops and while loops. 8. Control Flow in Swift: Hey, guys in this video will learn about control flows in Swift, so we'll talk about decision statements and looping constructs that's worth supports. Will start by learning about if, if else and Sweets case statement. Then we'll learn about while repeat and repeat while loops on different doctor four loops as well. So let's begin with decision statements, so the sincere statement consist off f statement if else and sweets cases. So just create a new playground, get a blank document and right control flu and saved whatever you want. Remove everything that's that, and we'll start with if statement if in defense. So you might have already knows you might already know this by the courts we have done now , and you might have understood it somewhat. So I'll explain you in Degale. So the simplest form of decision statement is the if statement. It simply checks a condition, and if it is true, it will execute the block off court. So let's say we have our percentage and it is 87. It's 37% to 87.7 so, and we write an if statement if for certain stage is greater than 35 0.0. Then execute this particular block this entire block on. We'll just ride friend bus and so did door to marry Grand going to see? Well, sure pass because that person date is greater than 35.0 sort of take If this particular condition is true, If it is true, it will run this part off court this and I apart whatever we keep inside this this throne bracket curly brackets on. Now let's have a Canadian else to it. So if there if this condition is not met, then else will bring I feel so if the person dates is greater than 35.0, then it will executive bus it will bring past. And if it is not, this condition is not so despite it, if it is less than or equal to 35 that it will print field. All right, So the simple If this is true, then then do this or oh, it is not true. Then do this else part Third shows prop past Now that the 17.7 Schofield getting me now we can have multiple. It's if statements so we can do that is we can write If a condition person deduce it's agreed a then equal do 85 then friend Excellent. Excellent score then edits If person days is greater than equal do 70 then brained good, good score It's if boys turned age is greater than equal to Oh, this must be 30 equal to 35 because $35 a pass greater than 35 foreign zito just 35 then their dues It is boss but needs to improved and s if it is less than 35 no condition is satisfied. If none of these conditions are satisfied, then it will go to else and it will bring Phil So if person data is greater than equal gratified that it will print excellent school. If it s fault, then it will go and take the second condition which is percentage is greater than equal to 70 And if it is true, then will print this and exit off the entire if statement. And if both of these are falls and even this is false, then it will take for third condition With this person is greater than equal to 35. If this is true, then it will print past but needs to improve. And if all of them are falls, then it will bring the else statement. So if none of the estate mental consider is true, then it will surely print an else statement. If you don't even write a statement that it won't print anything, it will just pass on the command to the next line. All right, so let's play. Whether it's 37.7. There was show, excellent school. The tracks lead school. Now, if I make it less than 85 bird greater than 70. Show me good school. And if it does, let's hear. 47. It is sparse but needs to improve. But if you choose less than 35 that was your field guarded. Howard works there in digest offer. Great. Now let's talk about sweet Statement. So a switch statement operates on a value and executes a court If it matches a party so we can match a single possible value on multiple values. However, the switch switch statement must be exhausted means that every possible value of the open must be a case. So let's take an example. Let's let my number is equal to seven, so we just take a switch case on De Paz. The value off my number so it will pass this particular variable my number and we're to check in each case whether we warned that number or not. So if he says zero, then with this print it print, my number is zero. And if it is one or even let's say begin animal dependent. Oh, we intake multiple values by this putting comma. When Goma three If it is 135 or seven for nine, then it noose. My number is our all right. Now, if you want some other case like we want to check with, the number is greater than 10. So we'll just put another case for it. Case Oh, that number is then is between Dan and 100. So tend ordered less than 100 between then and 99 including 99. So to take that and, friend, the number is between often and 100. And finally, if none of the cases a match, then default. This the four part off court is run. So being the separate none of the about solar drunk and see what it chose. My numbers are so if we put nine this year. Still, so my number resort perfectly. If it would do, then it will show none of the about. And if you put zero than my number is zero and go to the first case. And if report 56 that it will go to the third case with between 10 and 100 my numbers between 10 number getting me in addition to intervals, we can also matched pupils. However, since Stupples, we can have many different values. We use an underscore to match anything when we want to accept any value in that place. So let's see. Let point b beer to below zero comma zero and we want Do take a switch case off point on buzzer value point people and say the case is zero comma zero. Then I think it this at origin or the next cases case zero comma underscore. Which means that the first value of the people will busy should be zero and second will you can be anything. So in that case we can see that the point is on via axes. You know the graph system, right print it is at his own. Why excess on the same way if one of the cases on the school coma zero, that means it can have any value off X on just zero on the wife. So that means it is owned by ex right, So prayed it is on X X is first. Well, you can be anything on via value must be zero. So it is on X Texas, and if none of them matches, then begins a print coined is anywhere but the X and Y Xs, their mentor to can be anywhere but north on the X or Y axes are even on the region. So let's just try this. Let's say the point is that zero and 1989 So it will be a zero in any number in the second part of the people. Then it will show it is on my ex Isi. So now let's talk about fall through in sweet State wins, remember that? Oh, only one off the condition is satisfied. So if you put zero comma zero, this is executed. But not just because zero my anything can also zero comma zero right. But this is not executive only single oh cases executed in the sweat state went right So let's get a fall through statement in the first case in the score on Let's see what it does that's running. So when you're done this in the console, we get Oh, it is that orders in and it is on why excess. So whenever this condition is satisfied, it will run the print statement, and it will fall through for the next case off as well. So deluxe around Italy checked on X condition off next case, and if it is true, then we'll print. It is on y axis, and that's what fall to does. And we'll talk about break and continuing when we learn about the for loops. So now, after this, let's talk about looping constructs, which consists 04 loops by loops and repeat while Loops constructs Teoh. Let's start with by Luke. So while the simplest kind of fluke is a while loop, it is it will simply run until the condition is false. Let's look at an example. Let's say what countered is equal to zero. And while their condo is less than five, repeat this particular lines. Of course, friend the count and also initiate add one to the counter. We lose the compound oration, the real I'd want to the counter. So when you run it, you can see the counter this initialized with zero. Then it takes the wild condition. If it is less than fine, then it Woz going to surface fired. The condition is satisfied, and we'll print the rest of the core inside the while loop and for will print account of variable. And then I'm going to the counter. So in the next iteration, Carter becomes one the same two, then three, then four. Then when it becomes 55 his lessons they don't know it is equal to zero, so it will be removed from the while loop and has the control to the next line. So this was the simplest while Lou on, Let's see what a repeat. While Luke can do so, interpret while loop is almost exactly the same. Like why loop? Except with one condition that the loops condition is checked at the end. So we have the right. Let's save our count is equal to zero and repeat, so whatever be Oh, right in here will be repeated at least once and then at the end, or the condition will be checked with a while. So not this wife and the condition would be. It's a ground is less than minus one, so it is negative, which is not true, right at zero. So still, just to show you it will execute one, Sprint groaned, going sort of zero it it does not satisfy the condition, but since it will run the entire Ph statement ones so you can see counter zero it is. It is not satisfying with this condition, but Saturday's run once so the next we talk about foreign loops, foreign loops, so you might have seen this loops in some different part off radio earlier. So swift off was a sophisticated foreign loop that can be used to hydrate through a range. A set an area are dictionary, a collection off pupils and even many other structures. So in the problem in the previous collection Diab section, we have seen how to use for Lou Foreign loops to iterate over an area or a dictionary. So do look back in that video. In that course off, reduce on, you'll understand it better, so we'll start now. Let's see how we can I trade through 1 to 5 numbers with a simple for loop. This you can do? I guess so Just pause the video and do it yourself. It's check back with me, so I'll start no. Well pretty of then. For Gondo in the rain, you would be one daughter 10.5. That includes five Onda. We'll just print the count. Oh, so let's run it so you can see counter 12345 on. And there was a simplest for look you can do No if you want to trade the, uh I treat this number of times find number of times, but we don't want it to be assigned to a variable. So we do that by using an endoscope so far, underscore in 10 daughter 100.100 friend one last one is equal toe. It will just bring this Oh, this new many number of times so that you would just use from 1 to 10 so it will print out 10 times. One plus one is two. Just run it. We don't need a variable to initialize it inside a loop. So when president is too, it is run 10 times. You see simple. Now that you understood four loops. We will see how weaken Brown statements using continuing break so the continue statement will skip over the current iteration off any loop. Any court after the after the statement will escape for this iteration. The loop will continue to the next iteration directly. So in a big statement of the excitement will be Tom will terminate the closest Blue Do it. If we have two nested loops than and Big Break statement is used inside the second looks, then it will dominate the second look. The and it will continue to the or is no parent Luke, So we'll see Bodo continue and break statements. Election right now. So let's say for the sprint does this dish. So we say four. I in wondered ordered 10 we warned under the condition, If we'll take an if statement if eyes equal to equal to three, then what you do is you continue with the core on, and if eyes equal to equal to seven, then break on and Brent Con did I is I and in the end leads to start friend and off the loop. So let's run it. So start by reiteration from one and we go, It will check. One is not equal to three. And what is not able to seven? So it will just print counter eyes one. And will I treat again toe when the value is to the same with three or when it is 33 will be equal to three. So it will continue So it will not Oh run the next particular lines off court and regicide trade to the next item. So in three it won't be printed the counter street and it will pass the control to the next iteration. So to four I will before that will check and count friend outcome to rise for the same way It had really happened for five and six and then seven it will check. Our seven is equal to seven and it will break. It will break the entire loop so it won't continue till 89 10 It will break it seven itself So counter will be six. It will print out six and then murder seven. It will break it 1 to 1 friend. 7789 10 are not printer and at the end it will put print end off the loop. I hope your understanding this ISS Quite simple. So Alright, guys, there was the end off the control flu. We learned about FL statements with cases while loops and four loops on did you in the next part of the video, which is very important, their dysfunctions and swift. You're going to use it a lot Well developing iPhone, iPad applications or even normal programming in Swift. 9. Functions in Swift: So in this video we'll learn about functions and swift. We will see how to define and call various type close for functions. The function is a block off organized, reusable court that is used to perform a single related action. It is a self contained block off court newspapers this to perform a specific task. You can call that function any number of times, and it will execute that be soft core that is, inside the function and number of times. So we use function so that we can break up the main source scored into a proper for matter and manageable chunks. Of course, in order to reuse the court, Britain inside the function, we just have to call that function so functions as three main parts of the dysfunction name , input, parameters and return types. So we learn about them right now open of X Corps, create a new playground file. Blankfein and its name it its functions in desktop. So now let's create our simplest form or function. So to initialize the function, we use the Cheever funk and then died the name of the function first function, then put the round bracket and curly brackets Navarro, you right inside the car. The brackets will be the core off that function on. Whenever we call that function, the piece off court there, resident inside the function will be executed. So we just want this function Toe print. Hello? Now, this is the initial our declaration off the function. Now we're going to use the function. We will call the function. Oh, known your like first by writing the name of the function. First function and down brackets. No. When rebuilt on it, it will print Hello, world. No. If you want to print it twice, we just call the function again and it will print choice. Hello, world. Hello would see now we'll see how we can use functions with Jeremy does. So battery doesn't Something will pass on to the function and really use that by parameters inside the function. So let's say I will function full name on the function takes better on the doors. But I'm a deserter than all reason in the round brackets off the function so well. First name and we won't that be able to be off type string. And also last name. We want there to be string as well. So we'll print. Full name is first name space. Last name. Now we'll call this function by typing Bring. I'm sorry. Print. Full name. We'll call this function on. We have to pass the parameters. So let's say the first name is equal toe John, and we'll just have to relabel right. You're it off street data type string So forced me. And in the last time we can directly at the parameter last name You can see it is Watson to join what's in and every bring down dialogue. Name. Full name is John Watson. You can see this is a parameter books. Now, if we don't want this particular, we don't want the naming to come while we call the function, We can just do being desperate and endo School and space underscore in space before initializing though family do us So now when we call the function a friend, friend, Full name began directly our first name in the last name. That's name B. Watson. Are there still print? And John Watson. Full name is John Watson getting me great. So now you have seen hope around with those work, you know, function now. Let's see how we can return some value from their function. So what we want is will take a number and we'll pass that number to a function and will make that function. I would want to it and went to that number and return the value so right function. Add one and retake a number as beram widow and it must be an individual. And in order to write undertone well, if you're going to return a value, then were to write their data type were defined their data type of the function off that Britain value. So we do that by or dash and the greater than Rop and just write that beauty type of the return value. So we want the data type of the return value, Toby individual. So when we take the number so we want to everyone to that number updated number is equal to now. Remember that this number which we take is ah Jeremy toe. It is immutable. It is a constant and not a variable. So updated The most number plus one on will return abated number. This is an indie Joe and hence will return. The integer type must be the indigent return type must be in digital. That's why we do this as a part off return data type. So we'll use this on will use it in a Prince state. When directly friend 22 plus one is you start a function at one and pas though number just readyto the real print 22 plus one is 23 getting me, you know, in 24 34 Underboss 34 and related 1 to 34. Now you can see right through. It is a warning. So we're seeing that we're able updated Number was never muted, was never changed. So oh is asking us to make it as a constant and not a variable will change it too late. Swift also supports returning multiple values in the form off people's. So why don't you just go ahead and try it yourself and check the court along with me below ? Just take two numbers as import off a function, square it and return those two values. Return the reading. Both the values offer to pull together. So just right on, check it with me later on. So now in order to do that, Rick, you to function funk squared off square off two numbers on in the perimeter. We take two numbers X on distributable and why that would be a double as well. Now we want to return it so rather return diaper. Lots of beer, people. No se X one is doubling on. Next to is double. All right, so we'll take two numbers on put a square, root off them, and have done so. We take two numbers and or during the square root of them, so it is not square at the square. Root off two numbers, so let X square. Just make sure you have important foundation so that you can use the direct function off square root. Sq our teeth Energy X and let why square is equal toe sq rt off. Right Then we'll return the entire people by saying, Return on in brackets X squared. Oh, my wife's quit Certainly return the entire to pull off, but after square rooting it. So for print Riendeau square root square root off four and let's 16. The to 49 odd sq square root off four and 49 so when we print it, it will give us the square root of food and 49 92 and seven. We're getting me There was easy, right? Wait. We can also have ah, you know, to see if it doesn't people itself so we can save our and a do people. First number comma, second number Ondas equal toe square, root off. Ah! Nine on 64. Oops! 64. It returned the value off three and eight and started or likewise in four. Snowman. Second number Civil print. First number will be first number and second is second number. First name. Sorry. First number and take a numbers eight, three and eight. Other square roots off nine and 64. All right now. Oh, you know how functions work, right? Great. No, we'll see how we can use different parameter values. So if we want Oh, that's call. Let's create a new function fung big and that the base off that power bi are double and the exponents off that probably be doubly and redundant. Double 100 ona value The result double. There's already typed double. So we take the power Savile Row done using the function Paavo there some at function, so it will take you as the base and it with Cuba. Or will it take for a three at the base on a cube? That 23 multiplied right through my little red three? All right. And it will return that double toe wherever the function is called swells. A friend Just sit based your so free pass basis to so it will take. You brewed right here. So do multiplied by two motive library to Andi will say exponents. So if you pass the because the values basis to an exponent be too So it is to raise to do, which is four. So we'll print that and repent for for take The explanation does three. Then it will multiply The wood tries it will be to raise to three to do with the blood red to multiply right to which would be eight. Now let's say I want three and the exponents should also be three. So three days to three, which will be 27. All right, three more developed by a team of developers. Three. So this is the base and this is the exponents. Now what I want is we want to set the fourth parameter value So we'll take the exponent value default value as to on if you don't pass the exponents value on really the base value s three and put the exponent well, us too. Which is the default value. It will be three days to do, which is nine. All right, guys, they're reserved for functions and swift. I hope you like this sets of videos and I hope this class waas very much helpful to you and learning swift from scratch. We learned about installing X scored. Then we learn how playground works. And then we talked about variables and constants. Then we learned about characters and strings and served. Then we saw how operators working Swift, where we learned about assignment operator at Martic Compound Assignment operator and comparison operators. Then we talked about collection types in that we learned about areas and dictionaries and different functions associate associated with them. Then we saw how control flu books That is F statement if else switch cases while loops and four loops. And finally in this video, we learned about functions on. We saw how we can use pattern. We does in a function on return some values in the function. So I hope this sets off videos were very much helpful to you on if it will make sure you comes up, give a good rating and review to this course on Happy according to you guys.