# A Curious Case of Mistaken Identity: How Lambdas Break Data Class Hashing

DevFeed: [A Curious Case of Mistaken Identity: How Lambdas Break Data Class Hashing](<https://devfeed.tech/articles/a-curious-case-of-mistaken-identity-how-lambdas-break-data-class-hashing-27333.md>)

Original publisher: [Read original article](<https://blog.mmckenna.me/a-curious-case-of-mistaken-identity>)

Author: Matt McKenna

Published: 2024-11-14T21:44:31Z

Content type: tutorial

Language: en

Sources: [Matt McKenna](<https://devfeed.tech/sources/matt-mckenna.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [hashing](<https://devfeed.tech/topics/hashing.md>), [hash](<https://devfeed.tech/topics/hash.md>), [consistency](<https://devfeed.tech/topics/consistency.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [behavior](<https://devfeed.tech/tags/behavior.md>), [class](<https://devfeed.tech/tags/class.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [hashcode](<https://devfeed.tech/tags/hashcode.md>), [hashing](<https://devfeed.tech/tags/hashing.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [maintenance](<https://devfeed.tech/tags/maintenance.md>)

## AI overview

This Kotlin article explains why data class instances containing lambdas may compare as unequal and produce different hash-based behavior. Each lambda instance has a distinct identity, so the article recommends excluding the callback from equality and hashCode calculations, while noting the resulting maintenance cost.

## Source excerpt

Introduction: The Scene of the Crime It was a dark and stormy night. My hands were flying across the keys when suddenly the codebase began to exhibit strange behavior. Hashes, which once returned the same values for identical objects, suddenly became...