November 2016
Intermediate to advanced
480 pages
14h 42m
English
Functions can give you information after they finish executing the code inside of their implementation. This information is called the return of the function. It is often the case that you write a function to do some work and return some data. Make your divisionDescriptionFor(numerator:denominator:withPunctuation:) function return an instance of the String type.
Listing 12.8 Returning a string
...func divisionDescriptionFor(numerator: Double,denominator: Double,withPunctuation punctuation: String = ".") {print("\(numerator) divided by \(denominator) equals\(numerator / denominator)\(punctuation)")}divisionDescriptionFor(numerator: 9.0, denominator: 3.0)divisionDescriptionFor(numerator: 9.0, denominator: ...
Read now
Unlock full access