Posts

Showing posts with the label argument labels

Treehouse Intermediate Course - Part 10 (Closures 1)

Image
Yes! So completes the aim to get four consecutive days! I actually enjoyed generics more than I thought - the concepts were so difficult but it was interesting finding out about them. Now onto closures - the area of Swift that I find hardest of all! This is apparently a 146 minute course, so I'll likely need at least 5 or 6 entries for this. 24 separate steps, so yes - similar to generics in terms of length! After that, the other iOS intermediate track (there is some crossover there with the Swift one), has a few other projects and bits. So that will be next! OK, let's go! Start Time - 12:22 Functions as Data A key point already is that closures are not a type. It is more that they are 'anonymous functions'. Simple functions - a recap! func printString( _ string: String ) {     print ( "Printing the string passed in: \ ( string )" ) } printString ( "Jeff" ) We can create a constant/variable and assign a function to it. No ar...

Stephen DeStefano Swift 5 Course - Part 3 (Lectures 8 to 11)

Image
Well it's been a good few days but I'm back! No need for more of a preamble than that - straight into functions! Start Time - 14:06 Functions These are SELF-CONTAINED. It is best to name what the function actually does. Syntax - the name, parameters, return bit etc. Nothing else new here. Bit about the return value and print statement used. Underscore - placeholder for a constant/var without an actual name. 9 out of 10! Only one that was wrong was a bit of a trick question. OK next! Returning Multiple Values So this of course means returning a tuple All very technical - again, Stephen combines lots of elements - for loops, if statements, optionals...all hard to keep on top off! Names of return types - optional. Used to improve readability of code. Argument Labels and Parameter Names Argument label - used when calling the functions. Better for readability. Swift used the parameter name as the default. Labels are used on the outside - on the left of th...

Sandra L Course Part 3 (lectures 16 to 22)

Image
Well it's been a good few days! After so much success with my first proper app, it's been a shame not to capitalise on that. Having said that, I do feel recharged and ready to learn some more! My plan with Sandra's course is to keep with it for all of the recap. When it starts getting trickier, I'm going to work on an Xcode project for another app idea - got a few possibilities! So, let's continue with Sandra's course! Start Time - 13:29 Parameter Labels func add(number1: Int , number2: Int ) -> Int {          return number1 + number2 } add (number1: 4 , number2: 6 ) Again, easy stuff. The next step here is to use _ to have empty parameter labels.  OK - one useful distinction here between parameters and arguments. The argument is the external name - the one used outside of the code block. The argument label should read as a sentence e.g. using 'to' instead of 'name' in a sayHello function.  So "say hel...

Chris Ching Course Part 1 (Data types, If/Switch statements, Loops and Functions)

Here we go! Back to Udemy and consolidating with this course from Chris Ching. Spending a couple of weeks on Treehouse has not proved fruitful, though it was interesting to look at properties, initializers and a few other aspects at a higher level. Anyway, coding is one of these things where my understanding needs to be topped up. A bit like going to the gym! Some bits will be intact but I need constant topping up to make it at its optimum.  Start time - 15:02 Data Types *Just skimming over this! Different types of data are stored on the data differently. If the system knows it is an int, then it allows different things to a string, double etc. Type inference - he hasn't mentioned this but there is no need to specify the type. Xcode figures that out. Converting types - var number = 4 number = String(4) var/let - know all about these. Rounding function. Use the round() with the variable in the brackets. If Statements *Again, skimming through! Something I nee...