Wednesday, July 16, 2014

Swift - Function declaration and defination [ swift programming language apple ios]

Function declaration and defination
“Use func to declare a function.”
“func greet(name: String, day: String) -> String {
    return "Hello \(name), today is \(day)."
}”

“Functions can be nested.”

Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/in/jEUH0.l
return multiple values
“func getGasPrices() -> (Double, Double, Double) {
    return (3.59, 3.69, 3.79)
}”

like block
“numbers.map({
    (number: Int) -> Int in
    let result = 3 * number
    return result

    })”

0 comments:

Post a Comment

About

Powered by Blogger.