La variable 'xxx' n'a jamais été mutée, pensez à changer pour 'let'

Mis à jour à xcode7-bêta j'ai couru à travers une nouvelle sorte d'avertissement. Voici mon code

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
    var attributes: [UICollectionViewLayoutAttributes]? = super.layoutAttributesForElementsInRect(rect)
    if let layoutInfo = self.layoutInfo {
        attributes?.append(layoutInfo)
    }
    return attributes
}

le message d'avertissement est
Variable 'attributes' was never mutated, consider changing to 'let' constant

Pourquoi ne xcode dire Variable 'attributes' was never mutated?

Question De Mise À Jour

l'avertissement est allé quand j'ai modifier mon code pour ce

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
    var attributes: [UICollectionViewLayoutAttributes]? = super.layoutAttributesForElementsInRect(rect)
    if let layoutInfo = self.layoutInfo {
        attributes!.append(layoutInfo)
    }
    return attributes
}

donc contraint d'ôter peut l'emporter. Mais c'est peut-être pas une bonne chose non?

source d'informationauteur dopcn