Type Inference in Swift’s Closure

Kent
Feb 3, 2015

You may be overlook on type inference in swift programming language — Apple’s new programming language. It is more than just `var` or `let` without specifying the data type.

Here is an example:

Copy and paste the code to Playgrounds or REPL to try it out.

The simplified version is very clean and concise. This type inference feature let you create function that look like the first class citizen (e.g. `if` or `for`) .

Credit: Stanford’s Developing iOS8 App with Swift Course (Available via iTunes U Course via Apple Swift Portal)

--

--