Create a New Function in Swift

In this very short Swift code example, we will learn how to declare a new function in Swift.

If you are interested in video lessons on how to write Unit tests and UI tests to test your Swift mobile app, check out this page: Unit Testing Swift Mobile App

 // Declare a function
func sayHelloWorld() {
    print("Hello World")

// Call function

This was a very short code example. To learn more about functions in Swift have a look at this larger tutorial: Swift functions tutorial.


Leave a Reply

Your email address will not be published.