It also knows the closure must return a string, so we can remove that:

travel { place in
return "I'm going to \(place) in my car"
}

As the closure only has one line of code that must be the one that returns the value, so Swift lets us remove the return keyword too:

travel { place in
"I'm going to \(place) in my car"
}

Swift has a shorthand syntax that lets you go even shorter. Rather than writing place in we can let Swift provide automatic names for the closure’s parameters. These are named with a dollar sign, then a number counting from 0.

travel {
"I'm going to \($0) in my car"
}

Love Hacking with Swift?

Get all 40 projects in PDF and HTML: buy the Hacking with Swift book! It contains over 1300 pages of hands-on Swift coding, and will really help boost your iOS career