Day 5 of 100 Days of Swift

Days 1 to 12 of the “100 Days of Swift” course make up the “Introduction to Swift” section.

Day 5‘s lesson covered functions, parameters, and errors. The specific topics were: writing functions, accepting parameters, returning values, parameter labels, omitting parameter labels, default parameters, variadic function, writing throwing functions, running throwing functions, and inout parameters.

Thoughts about Day 5

The Swift language’s usage of functions and features such as ‘throwing’ and ‘inout’ were to me different enough from how functions are implemented in Java that I found this Day’s lessons more challenging to work through than the earlier Days.

Some notes that I made while working through the Day 5 lesson:

  • 3. Returning values
    • The Optional reading does a great job explaining the differences between expressions and statements.
    • Tuples make great candidates for returning multiple values from functions.
  • 4. Parameter labels
    • Parameter labels is a great idea and feature because it helps me better identify the input(s) expected by the function.
  • 5. Omitting parameter labels
    • Omitting parameter labels by placing an underscore _ in front of an external parameter’s name to allow calling of a function without having to call the function with parameter names is a cool feature.
  • 6. Default parameters
    • Being able to give a default value for a function’s parameter(s) is a handy feature. Reminds me of the programming concept of method overloading.
  • 7. Variadic functions
    • Remember that variadic functions accept any number of parameters of the same type.
  • 8. Writing throwing functions
    • I need to work through this topic again tomorrow after letting the initial reading of the material toss around in my mind overnight.
    • Make sure to re-read in the Optional readings the external article by Donny Wals about throwing functions.
  • 9. Running throwing functions
    • Remember that you can’t just call a function by the function’s name alone if the function uses throws.
    • Remember that throw functions must be executed using the three keywords do, try, and catch
    • For extra practice consider writing my own examples of throw functions and then execute the throw functions using the do/try/catch.
  • 10. inout parameters
    • inout parameters look to be equivalent in usage to pointers in C. Further investigate this.

It took me 2 hours 45 minutes to go through all of material (videos, main and Optional texts, links to external additional reading materials, and Tests) given for the Day 5 lesson.


Today’s total study time: 2 hours 45 minutes

100 Days of Swift cumulative study time: 11 hours 15 minutes