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