Posts

Showing posts with the label Loops

Stephen DeStefano Swift 5 Course - Part 6 (Lectures 23 to 25)

Image
Yes cracking on! Got a bit of time this morning before heading to my Uncle's and Auntie's. I want to cover Optionals then Control Flow. All very doable! Let's go! Start Time - 08:19 Optionals So I know about these but good to go over! They're used in situations where they may not be a value stored. Nil means the absence of a valid object. You can do these for any type at all. Optional types are returned where there may not have been a value e.g. when converting from string number to actual int number. The question mark syntax. Good way of understanding this is that the ? QUESTIONS whether something may not have a value. So the question bit is key there! You can only use nil with optionals. Optionals can only be var as the values are likely to change. If you create an optional without an initial value then it automatically sets this to nil. Forced unwrapping Comparing the optional against nil.... That's not forced unwrapping - that's just ch...

Nick Walter Swift 5 Course - Part 1 (lectures 1 to 15)

Image
Well, this has been the worst effort for a long, long time! An entire month! There's no point fretting about it - that will not achieve anything. I've felt a renewed sense of wanting to achieve with coding. At this point, it makes sense to switch to a new Swift 5 course, as the language has been updated. It will also give me a chance to consolidate and ensure my understanding of the basics is solid. Then I will resume with Angela's course! So not a cop out. OK, let's get stuck in! Start Time - 14:00 Just looking at Nick's course, there are 6 hours of content here. Perfect for the next few entries - possibly just even the next couple of days' worth. A lot will be the basics, but that's fine. Intro/Installing Xcode - skipping through all these! Don't need the Linux/Windows ones either. Swift Basics This is going from absolute beginner, so rather than totally skipping through and onto Intermediate, I'm going to just do a general skim over. S...

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)

Image
No time to waste! Only got a short amount of time now so going to get a few minutes or so in! Start Time - 20:14 Conditionals If statement for 'love calculator' example. So a simple example for this. The idea will be that conditionals are used to show that the print statement will do it differently for whatever the number is. With updated Swift, I would use the Int.random(0...100). Easy fix that would be. Also no UIInt32 needed but just an Int. So with the if statements, it would be a STRING being returned.   Linked to the whole choose your own adventure - if/else for each choice. BMI Challenge No need to do this - easy enough to be honest. Just skimming through. BODMAS principles... So something I picked up on before is not needing the greater than AND less than value for the middle line (for the else if bmi > 18.5) A better solution, which Angela is already explaining before I could say it is returning a string instead of a Double. So the...

EDU Course Challenges 1

So I don't feel quite ready to resume Angela's course! No, I've had a look through the other Udemy courses I've purchased and have decided to test out the challenges from the EDU one. I just enjoyed the last few so much that I want to get stuck in and apply what I know before I go back to Angela's. OK here we go! Start time - 20:39 Challenges for types etc. 1. Type this code in a playground: var num = 5 num.advancedBy(3) What is the result? We talked about advancedBy in connection with String indices. What does this result tell you about these indices? Do the .successor() and .predecessor() methods also work with Ints? Does the .predecessor() work when num is 0? I've never actually come across advancedBy before. It will be interesting to see if the latest Xcode even recognises it! So I assume the answer will be 8! num . advanced (by: 3 ) Indeed, the syntax has chosen since this EDU course. No bother, I fixed it easily and the answer...