Question:

What output will be produced by the code below?

func greet(var name: String) {
    name = name.uppercased()
    print("Greetings, \(name)!")
}

greet("River")

Correct answer: This code will not compile.

Explanation: The greet() method declares its name parameter using the var keyword, which was allowed only in old versions of Swift. From Swift 3.0 onwards this construction is no longer valid, so the compiler will refuse to build this code.

 


Keywords:

© 2017 QuizBucket.org