Coursera Introduction to Programming in Swift - Part 2

First off, sorry to Coursera for putting the extra letter in the name - managed to bungle that! Here we go with part 2 - a quick entry here, just to focus on whatever is next. 

Right this bit is from Mark Price - from Devslopes which is the company I've seen him from before. Will probably be a lot of recap: Bools and Conditionals.

Booleans and Conditional Logic

A lot of waffle here so far - sorry Mark Price! For a newbie, then fair enough but I know this stuff. Good that it is very familiar and just sacrosanct information at this point. 

More practical uses - if something has e.g. downloaded - then it can have a Bool - a true/false. 

All of the less than, greater than etc. etc. 

If statements - using greater than or less than, then the print statement. With Ints, with Strings etc. etc. 

Straight onto the review. No point messing around! Review and challenges done - all good. 

A good time to stop - will continue the next bit of logic etc. later. 


OK, I'm picking this up a day later. What I did about conditional operators and arrays did not work. No bother as all of that was easy!

One thing I noticed with the challenge was I thought that the code would not compile, but actually it was the other option - will compile but crash. This highlights something: that you can create code which is technically correct but crashes at run time - when the play button hits. Got it!

Loops

OK, again this is going to be a LOT of recap so just skimming it through. I won't get into detail again but I find Mark Price waffly and trying too hard to be funny. 

I've always got the basics of these but struggle when they start getting nested or more complex. For now, I get the use of 'repeat'. It does the calculation first, then sees if it meets the condition. So it can break the rule before it then pulls out. 

For...in loops are neater for me. You don't need to add the increment as this is assumed however the value is automatically a constant so cannot be mutated - that can prove tricky. 

There is another forEach loop - with Swift 5 onwards but that is not covered here. 

Right challenge with 5 questions.... It says 5 questions but is only one. I totally misunderstood this so put it into Xcode. Now it makes sense!

Next challenge - the playground with loops challenge. No one actually checks this. So far, I feel that Coursera is not very thorough to be honest. 

OK a couple of cool things came up! To do a loop in reverse, you can use the .reversed() method after the numbers descending. That could be useful!

Right, a good time to stop. Here is what I've covered recently:

Bools
Conditional logic
Logical operators including unary etc.
Loops - different types and application
Arrays
Loops with arrays

I'll be back tomorrow - getting on a roll now!

Comments

Popular posts from this blog

Coursera Introduction to Programming in Swift - Part 4

Coursera - Intro to IOS Development Part 1