Conclusion

In the last demo, you updated the Fibonacci code to be a function that returns a digit in the sequence based on an input to the function. You also updated the code to make sure the input to the function is valid and doesn’t cause a crash.

You covered a lot of important topics in this lesson:

  • You learned about flow control and how to make your code branch using if-else and switch, and learned about the differences between them.
  • You learned about different kinds of loops: for, while, and repeat while. You also learned how to interrupt their flow using break and continue.
  • You learned about structuring your code with functions and how to pass inputs to a function. You learned how to adjust the naming so it’s easier to read the function and avoid confusion for the order of parameters. You saw how to receive an output from a function and learned about the defer statement.

In the next lesson, you’ll learn about some more building blocks that Swift uses: struct and class. You’ll also learn about important distinctions between struct and class. You’ll get a better understanding of how memory is used for your variables and how much space they take.

See forum comments
Download course materials from Github
Previous: Function Demo Next: Functions & Flow Control Quiz