How to declare function with returnType in swift?

0 votes
57 views
asked Jan 12, 2015 in Swift by admin (8,115 points)
Hi All

  How to declare function with returnType in swift?

1 Answer

0 votes
answered Jan 12, 2015 by kalpana (3,995 points)

Hi

  Use func to declare a function. Call a function by following its name with a list of arguments in parentheses. Use -> to separate the parameter names and types from the function’s return type.

      func greet(name: String, day: String) -> String {

            return "Hello \(name), today is \(day)."

        }

        greet("Bob", "Tuesday")

...