Recap: Part 1 of My First Week of Learning Swift
Tags: ios, beginners, swift
Published: 2021-06-26 18:54:48

Hello ! I want to recap my first week of learning Swift. This will be a brief explanation of topics covered. If you write and speak it, it will stick.

**Days 1 and 2:**

**Strings: Multi-Line Strings and String Interpolation** 

*This was a review for me in a way because I started learning Swift on codecademy.com. Multi-line strings and string interpolation were new for me. Multi-line strings are used when we want line breaks in our string. In order to do that we need two sets of three quotations wrapped around the string and the quotations must be on their own line. Multi-line string can also be used when we want our code to look neat but do not want the line breaks. To do this, just add a backslash after each line.* 

*String interpolation allows us to place a variable in our string by adding a backslash and wrapping the variable in parentheses. \(variable).*

**Arrays, Tuples and Sets**

*Arrays, tuples, and sets are used to store several values into a single value. However, they do have their differences.  Arrays are a collection of values that can be accessed by calling the items numerical position. In arrays the numeric position starts with 0 a.k.a zero-based. Tuples store several values into a single value but items cannot be added or removed, item types cannot be changed and they can be accessed by numerical positions or by their name. Sets store values but they are unordered when called and items cannot appear twice.*

**Dictionaries: Keys, Values and Strings**

*They do exactly what you think they do. Dictionaries use keys and values. I like to think of it like the key is the word we are looking up in a dictionary and the key is the meaning of the word. In this sense it holds data about the key.*

*Arrays, sets and dictionaries are collections. When creating empty collections arrays and dictionaries have their own special syntax.*

*Enums are a way of defining groups of related values using using case.We are able to add associated values to each case.*

**Days 3 & 4:**

**Operators** 

*Here are different operators and what they do. Compound assignment operators (+=, -=, *=) are a short way of writing variable = variable + 50. Comparison operators (== and !=) are used to check for equality and other comparison operators like <=, >= , < , and > are used to compare values. The And (&&) and Or (||) operators are used to combine conditions. The ternary operator is used as a short way of writing a condition. Range operators have two options:*

*1. The half-open range operator, which is a range that includes its final value (1...5 would be 1,2,3,4,5).* 

*2. The closed range operator, which is a range that excludes the final value(1..<5 would be 1,2,3,4).*

**Conditions**

*Conditions are used to determine an outcome if a statement is true or false and what to do in each instance. If statements can be read as if x is = xx then run this code.  If and else if statements are used in conditions.Else if statements are in between if and else statements and offer another code to run if the condition is different.* 

*Switch statements are used when we have a lot of if else statements. It makes it easier to read and understand. Swift will run each case but if you want to continue to the next case use the keyword fallthrough before the default.*

**Loops**

*There are for loops, while loops, a way to exit loops and even skip items in a loop. For loops are used with arrays and ranges with the keywords "for" and "in". Every time the loop goes around it pulls out an item and assign it to a constant. It can be read as for every number(the constant) in numbers run this code. We give a while loop a condition to check and it loops the code until the condition fails. To exit a loop we must use the break keyword and to skip items in a loop we use the continue keyword.* 

*To be continued...*