Question:

When this code is executed, how many items will the names array contain?

var names = [String]()
names.reserveCapacity(2)
names.append("Amy")
names.append("Rory")
names.append("Clara")

Correct answer: 3.

Explanation: The reserveCapacity() method is there to let you give an indication of how many elements you intend to store in an array, but it does not place any sort of limit.


Keywords:

© 2017 QuizBucket.org