Posts

Showing posts with the label Chris Belanger

Ray Wenderlich Fundamentals Course - Part 5

Image
OK last part! I'm going to complete this fundamentals course today! Also, Xcode looks like it's ready for the official update - so I won't need Beta anymore. Anyway, time to go for it. Start Time - 20:44 Structures Grouping sets of related data together. Technically, all of the below are structs!   struct Student {          let name : String     let grade : Int     let pet : String ? } let bobStudent = Student (name: "Bob" , grade: 33 , pet: nil ) Most of this is recap so skimming through *Technical glitch for 5 approx minutes. Wifi back on! Mutating. I've made sense of this at last! If you do a function that alters one of the STORED PROPERTIES e.g. grade, then I have to use the mutating keyword. Cool.  Value type. I could clone an instance. That new version is unique and does not affect the original. Class (reference types) do.. It's also got to be a var, to change any of the va...

Ray Wenderlich Fundamentals Course - Part 4

Here we go! Last chapter of the course for fundamentals. This one is a bit longer so may need two entries. Let's go! Start Time - 17:39 Compound types - e.g. for tuples. This is about information being bundled together. Value and reference types - we'll be coming to that! Functions func printPass (grade: Int , pass: Int ) {     if grade >= pass {         print ( "Your grade score of \(grade) has passed! You passed by \(grade - pass) ." )     } else {         print ( "Your grade score of \(grade) did not pass!" )     } } printPass (grade: 72 , pass: 50 ) I've elaborated on this a bit.  OK, difference between parameter and argument. It's called parameter when declared. When called, and providing values, it is an argument! Cool, that does clarify.  func printHighestGrade ( _ grade1: Int , _ grade2: Int ) {          print (grade1 ...

Ray Wenderlich Fundamentals Course - Part 3

Yes! Finally some momentum. I'm basically going to continue with the Fundamentals. No more than 45 minutes to help out the old eyes! Start Time - 19:47 More Collections Dictionaries Mostly recap I reckon. Key-value pairs, unordered etc. Interesting - you can't have the same key! Didn't know that to be fair. Not going to put the whole dictionary in but some stuff you can do: for (name, pet) in namesAndPets {     print ( " \(name) has a pet called \(pet) " ) } let thorPet = namesAndPets [ "Thor" ] ?? "Nothing for thor" The second one of these is nil coalescing. It's a bit like ternary. These are pretty cool too: for (name, _ ) in namesAndPets {     print ( " \(name) has a pet!" ) } for pet in namesAndPets . values {     print (pet) } Challenge time! All good! One thing to check was adding a new item - needed to use the syntax NOT with update value.  Sets Have ...

Ray Wenderlich Fundamentals Course - Part 2

Image
Yes! First consecutive entry for a little while. Good news - I have sorted out the UI stuff so I have Mac OS Catalina - the beta version. I've changed my account so I get to have the beta stuff basically - ahead of time. So when the actual update comes up, I will just get that for the 'normal Xcode'. Anyway, I want to complete the fundamentals course. It's been very, very basic so far. So will skim through the content and just get to the challenges. Also, I'm aiming for no more than an hour at a time, but in 2 possible stints today. So stint 1 is to get the next chapter done. Here we go! Start Time - 11:49 COLLECTIONS Tuples One thing to type - that you can assign multiple values in brackets to the entire tuple, then each of those values is saved separately. let wrestlingFacts = (name: "Kevin Owens" , didWin: true ) let ( name , wonMatch ) = wrestlingFacts So now 'name' and 'wonMatch' are their own values. I could use ...