How to define swift functions?

Example:


  func greet(name: String) -> String {
      return "Hello, (name)!"
  }
  print(greet(name: "Alice"))  // Outputs: Hello, Alice!
  

Solution:

Functions in Swift are defined using the func keyword.

Beginner's Guide to Swift