Functions in Swift

Functions are blocks of functionality that you can call, pass parameters to, and return parameters from. They are used to accept returnn Tuble which is a convenient way to return multiple values at once.

In Swift, we can write functions this way:

   1:  func GetADrink(drinkName:String) {
   2:      var test = drinkName
   3:  }
   5:  GetADrink("Mango Juice")

One of the best things about Objective C is its self-documenting codes when it comes to functions. When reading a function call in Objective C, you can immediately tell what parameter is what. This is because parameter names are right there with invocation statement.

Here are some other uses of functions in swift:

Leave a Reply

Your email address will not be published. Required fields are marked *