NEW: Nominations are now open for the 2019 Swift Community Awards! >>

Spot the error

This Swift code contains one error – can you select the line that is incorrect?

Tip: You should mentally run the code from top to bottom, meaning that if line 3 says an integer should be returned and line 10 tries to return a string, line 10 is the wrong one.

func takeTrain(distance: Int, destination: String) -> String {
    var str; String = "I'm going to \(destination)\n"
    str += "Distance is \(distance)km"
    return str
print(takeTrain(distance: 5, destination: "London"))
Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code