Stephen DeStefano Swift 5 Course - Part 2 (Lecture 7)
So a busy few days; no time at the weekend at all to code! No issues - I've got a little amount of time today and will certainly make more time for coding this week. Going to continue with Stephen's course!
Start Time - 19:52
Tuples
Skimming through this. Multiple values declared together. It is not limited by a certain type.
Use of . syntax e.g. .0, .1, .2 - indexes like an array.
You can name the values in a tuple - this improves the readability. Still use the dot index or the name of the property. Either way.
Decomposing - breaking down the tuple and storing elsewhere.
You can use empty parameter name (__)
Iterating through dictionary by the use of tuples -

So the tuple names in brackets have been created for the purpose of iterating.
Another example -

In the above, the use of tuples is in the return value part. That's cool - I've generally only used one type in the return part. Cool!
So I've noticed something. Stephen throws in a LOT for what should be a simple concept. Combining functions, optionals...things that have not even been introduced yet! A lot to make sense of, very quickly.
Quiz - 10 out of 10!
So a key point with tuples is that they are good for TEMPORARY values. It is better to use complex data structures like structs/classes. For the latter, values and properties are better linked together. Tuples can still be useful though.
Finish Time - 20:16 (24 minutes total)
Next time, I want a 'proper' session to focus on functions!
Start Time - 19:52
Tuples
Skimming through this. Multiple values declared together. It is not limited by a certain type.
Use of . syntax e.g. .0, .1, .2 - indexes like an array.
You can name the values in a tuple - this improves the readability. Still use the dot index or the name of the property. Either way.
Decomposing - breaking down the tuple and storing elsewhere.
You can use empty parameter name (__)
Iterating through dictionary by the use of tuples -

So the tuple names in brackets have been created for the purpose of iterating.
Another example -

In the above, the use of tuples is in the return value part. That's cool - I've generally only used one type in the return part. Cool!
So I've noticed something. Stephen throws in a LOT for what should be a simple concept. Combining functions, optionals...things that have not even been introduced yet! A lot to make sense of, very quickly.
Quiz - 10 out of 10!
So a key point with tuples is that they are good for TEMPORARY values. It is better to use complex data structures like structs/classes. For the latter, values and properties are better linked together. Tuples can still be useful though.
Finish Time - 20:16 (24 minutes total)
Next time, I want a 'proper' session to focus on functions!
Comments
Post a Comment