Swift Function Return Type
// function definition func findSquare (num: Int) -> Int { var result = num * num return result } // function call var square = findSquare(num: 3) print("Square:",square)
how to set return type swift
func aFunction() -> <RETURN_TYPE> { return <RETURN_TYPE> } //call function like this aFunction()
Function Return Types in swift
func functionWithReturnType() -> String { return "I must return a string"}
Source: medium.com
Swift Function Return Type
func addNumbers() -> Int { ... return sum }
Swift Function Return Type
// function definition func findSquare (num: Int) -> Int { var result = num * num return result } // function call var square = findSquare(num: 3) print("Square:",square)