This repository is to record my journey learning Swift programming with Hacking with Swift.
On the other hand, the README will be a place to show the summary of each day learnings.
-
Day 1 (Variables, simple data types and string interpolation) – 27 July 2021
- You make variables using
var
and constants usinglet
. It's preferable to use constants as often as possible. - Strings start and end with double quotes, but if you want them to run across multiple lines you should use three sets of double quotes.
- Integers hold whole numbers, doubles hold fractional numbers and booleans hold true or false.
- String interpolation allows you to create strings from other variables and constants, placing their values inside your string.
- Swift uses type inference to assign each variable or constant a type, but you can provide explicit types if you want.
- You make variables using
-
Day 2 (Complex Types) – 28 July 2021
- Arrays, sets, tuples, and dictionaries let you store a group of items under a single value. They each do this in different ways, so which you use depends on the behavior you want.
- Arrays store items in the order you add them, and you access them using numerical positions.
- Sets store items without any order, so you can’t access them using numerical positions.
- Tuples are fixed in size, and you can attach names to each of their items. You can read items using numerical positions or using your names.
- Dictionaries store items according to a key, and you can read items using those keys.
- Enums are a way of grouping related values so you can use them without spelling mistakes.
- You can attach raw values to enums so they can be created from integers or strings, or you can add associated values to store additional information about each case.