Posts

Showing posts with the label Enumerations

Ray Wenderlich Functions and Types Course - Part 7

Image
Here we go! Tricky to get much done this week as I've been working on an application for a potential promotion at work. This is a big deal - if I do get it, it will mean a substantial difference to me short and long term. If I don't, then it may well be a sign that I need to ease my way away from teaching... we shall see! In the mean-time, back to Catie's course. Still a fair bit to do. Aiming to finish it in a few more entries.  Start Time - 17:48 Switch Statements All of this is fine so far. Enums from before used... enum Month : Int {   case january = 1 , february , march , april , may , june , july , august , september , october , november , december } enum Season : String , CaseIterable {   /// ☃️   case winter   /// 🌸   case spring   /// 😎   case summer   /// 🍂   case autumn } func getSeason (month: Month ) -> Season {     switch month {     case ...

Ray Wenderlich Functions and Types Course - Part 6

Two days in a row baby! We're onto enumerations first. I want to get a couple more entries this week to finish this course, consolidate then explore more on rw.com. Start Time - 18:50 Intro Enums take advantage of type safety - options to choose from. They are value types. Enums Mostly recap here. Case syntax, raw values. Own raw values can be put in. enum Month : Int {          case january = 1 , february , march , april , may , june , july , august , september , october , november , december } let month = Month . january func monthsUntilChristmas (from month: Month ) -> Int {          Month . december . rawValue - month. rawValue } enum Season : String , CaseIterable {          /// ❄️     case winter          /// 🌾     case spring          /// 🌞     c...

Stephen DeStefano Swift 5 Course - Part 8 (Lectures 32 to 38)

Image
Yes, two in a day! As mentioned earlier, I want to crack on and get the technical stuff DONE! Just want to get on to the projects. So the plan is to get at least collections done, then hopefully enumerations (maybe error handling too!) Start Time - 20:08 Arrays Again, as with other stuff in this course, I know this well so more of a skim through. A couple of cool things. The default value part is the same item repeated basically. The adding two arrays together means a bigger list basically. Can use the isEmpty property. Then use that within an if statement. Other stuff insert at, append, remove all etc. So using the range ... to put in several values at once. Iterating over the array. Use of the if let to see if an item is in the array. Use of sorted function. Then 'by'; you can use the < or >. Or others probably! Quiz - 10 out of 10 and one of the easiest so far! Dictionaries The syntax and concept of these is absolutely fine. Key-value pairs...

Sandra L Course Part 4 (lectures 23 to 29)

Image
Well, what a busy time it has been - hence the lack of entries! Not going to go into detail; I just want to crack back on with my work! I have missed it and am not going to recap anything at all, just continue with where I got to. So far, Sandra's course has been easy but useful for some consolidation. I'm sure it will get harder soon! Start Time - 19:15 If/else statements If statements - that all seems pretty logical so far. let temp = 20 let sun = "Sunny!" let clouds = "Cloudy!" if temp >= 20 {     print ( sun ) } else  {     print ( clouds ) } Another example -  if temp >= 20 {     print ( sun ) } else if temp > 10 {     print ( clouds ) } else {     print ( "Awful weather!" ) } They key thing here is that the if/else block is followed in order. If more than one statement is true - like in the one  above (temp being treater than/equal t...