How to write a function in Swift

First time here? Get started in my Swift guide.


Functions are coded to perform actions and manipulate variables. They are part of a core component in programming. In Swift, functions are very simple to write and, if you have a basis of Object Oriented Programming, you can reuse them throughout your program.

Functions are used in all sorts of programs. You can write a function to calculate the number of calories you ate this morning (I ate a lot, btw), how many miles you should run to burn them or even if you can purchase a book using your credit card!

Defining a function

In Swift and other programming languages, a function is defined by using the func keyword followed by its name, optional parameters, execution path and a return value. Continue reading “How to write a function in Swift”

Advertisements

Getting started in Swift

Welcome!  

This post will serve as an intro and reference guide to all Swift posts and tutorials which I’ve been working on to post on my blog. Feel free to comment your thoughts and feedback in this section and all posts from me you come across. 

I will keep this section updated on a logical path for you to get the most of this great language!  

Ready to Swiftify?

Continue reading “Getting started in Swift”