Posts

Showing posts with the label subscripts

Bob Lee Course Part 9 (Consolidation of chapter 1 - lectures 1 to 15!)

Image
Yes, it's time for some consolidation baby! I could just do so for the past few lectures but it makes more sense to go through chapter one in its entirety. If anything does seem really familiar, that's fine - I will obviously spend less time on that! OK, here we go! Start Time - 17:35 Lecture 1 - Course Overview (skipped!) Lecture 2 - Introduction Key tip to takeaway from this summary is NOT just to click on the 'fix errors' when the 'red' errors come up. They can lead to more errors and mess up the code - then be impossible to track back and sort out! Lecture 3 - Optionals So the big question here is WHY use optionals in the first place. Something to remember here is that Swift is the only language (well, one of the very few at least) that uses optionals. They are a great feature! *Right, rather than play the videos again, I am actually going to use Bob's lecture notes from here: https://www.bobthedeveloper.io/course/swift/1000-swift-fundame...

Bob Lee Course Part 6 (lessons 9 and 10)

Image
So back to Bob's course we go! Last time I spent a fair old while focusing on consolidation, which was really worthwhile. I definitely understand type casting, error handling, generics...all of that better than before! Well, here we go. Onwards to the next lesson! Start Time 19:32 Subscripts So Bob refers to this as wanting to use a shortcut for using a method when creating an object.... So here is an example of an array of days within a WeekDays struct, then a subscript used to return a string. struct HealthInfo {          var info = [ "Height" : 176 , "Weight" : 67.4 , "Body Fat" : 12.5 ]          subscript (key: String ) -> Double {         if let newInfo = info [key] {             return newInfo         } else {             return 0         }     } ...