Inspectopedia
 
2024.3

Augmented assignment creates a new collection under the hood

Info
New
Last modified: 03 December 2024

Reports augmented assignment (+=) expressions on a read-only Collection.

Augmented assignment (+=) expression on a read-only Collection temporarily allocates a new collection, which may hurt performance.

Change type to mutable quick-fix can be used to amend the code automatically.

Example:

After the quick-fix is applied: