Posts

Showing posts with the label value

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         }     } ...