Swift: Creating an Array with a Default Value of distinct object instances
问题 I noticed a bit weird ( and dangerous IMHO ) behavoir in Creating an Array with a Default Value . As stated in Swift 2.1: Collection Types Swift’s Array type also provides an initializer for creating an array of a certain size with all of its values set to the same default value. You pass this initializer the number of items to be added to the new array (called count) and a default value of the appropriate type (called repeatedValue): The point is: same default value ; in order to understand