# Beware of the order of operands in some Kotlin Collection operations

DevFeed: [Beware of the order of operands in some Kotlin Collection operations](<https://devfeed.tech/articles/beware-of-the-order-of-operands-in-some-kotlin-collection-operations-37159.md>)

Original publisher: [Read original article](<https://arkadiuszchmura.com/posts/beware-of-the-order-of-operands-in-some-kotlin-collection-operations/>)

Published: 2022-02-01T00:00:00Z

Content type: article

Language: en

Sources: [Arkadiusz Chmura](<https://devfeed.tech/sources/arkadiusz-chmura.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>), [optimize](<https://devfeed.tech/topics/optimize.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>)

Tags: [collection-operations](<https://devfeed.tech/tags/collection-operations.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [optimize](<https://devfeed.tech/tags/optimize.md>), [performance](<https://devfeed.tech/tags/performance.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>)

## AI overview

This article investigates why reversing the operands in some Kotlin collection operations can produce substantially different execution times. It finds that the difference is caused by the type of the second operand, particularly when it is not a Set, and that the issue applies from Kotlin 1.6 onward.

## Source excerpt

The order of operands can drastically affect the performance of your code.