Question:

What output will be produced by the code below?

func greet(_ name: String = "Anonymous") {
    print("Hello, \(name)!")
}

let greetCopy = greet
greetCopy("Dave")

Correct answer: "Hello, Dave!".

Explanation: This code assigns the greet() method to the greetCopy constant, which means you can then call greetCopy() as if it were greet().

 


Keywords:

© 2017 QuizBucket.org