Skip to content

Commit

Permalink
Day 4
Browse files Browse the repository at this point in the history
  • Loading branch information
rajhraval committed Jan 4, 2020
1 parent 0ede2a1 commit 955c92f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Day4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Day 4 - HackingWithSwift - 100DaysOfSwiftUI Challenge

> It's hardware that makes a machine fast, but it's the software that makes a machine slow. - Craig Bruce
### Loops

Today I learnt about:

- For loops
- While loops
- Repeat loops
- Exiting loops (ie: ```break```)
- Exiting multiple loops
- Skipping items (ie: ```continue```)
- Infinite loops

The summary of the entire day was:

- Loops let us repeat code until a condition is false.
- The most common loop is ```for```, which assigns each item inside the loop to a temporary constant.
- If you don’t need the temporary constant that ```for loops give you, use an underscore instead so Swift can skip that work.
- There are ```while``` loops, which you provide with an explicit condition to check.
- Although they are similar to ```while``` loops, ```repeat``` loops always run the body of their loop at least once.
- You can exit a single loop using ```break```, but if you have nested loops you need to use ```break``` followed by whatever label you placed before your outer loop.
- You can skip items in a loop using ```continue```.
- Infinite loops don’t end until you ask them to, and are made using ```while true```. Make sure you have a condition somewhere to end your infinite loops!

**That's all for the Day 4 of 100DaysOfSwiftUI!**

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Daily practices and my journey for the 100DaysOfSwiftUI Challenge.

### :pushpin: What's New Today?

- [Operators and Conditions](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day3.md)
- [Loops](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day4.md)


### :clipboard: Topics
Expand All @@ -16,5 +16,6 @@ Daily practices and my journey for the 100DaysOfSwiftUI Challenge.
- Day 1 - [First Steps in Swift](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day1.md)
- Day 2 - [Complex Data Types](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day2.md)
- Day 3 - [Operators and Conditions](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day3.md)
- Day 4 - [Loops](https://github.com/rajhraval1/My100DaysOfSwiftUI/blob/master/Day4.md)

**Happy Learning!**

0 comments on commit 955c92f

Please sign in to comment.