O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calling All Functions

One of the big differences between Swift and Objective-C is how parameters work when a Swift function is called. If you love the verbosity of Objective-C, like I do, keep in mind that parameter names are not included externally by default when a Swift function is called:

 func hello(name: String) {
  println("hello \(name)")
 }
 
 hello("Mr. Roboto")

This may not seem so bad until you add a few more parameters to your function:

 func hello(name: String, age: Int, location: String) {
  println("Hello \(name). I live in \(location) too.
  When is your \(age + 1)th birthday?")
 }
 
 hello("Mr. Roboto", 5, "San Francisco")

If you only read hello("Mr. Roboto", 5, "San Francisco"), you would have a hard time knowing what ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required