# Beyond Positions: Kotlin's New Name-Based Destructuring

DevFeed: [Beyond Positions: Kotlin's New Name-Based Destructuring](<https://devfeed.tech/articles/beyond-positions-kotlin-s-new-name-based-destructuring-25979.md>)

Original publisher: [Read original article](<https://proandroiddev.com/beyond-positions-kotlins-new-name-based-destructuring-eee347d1bb5c?source=rss-711ab22c5c77------2>)

Author: Nav Singh

Published: 2026-03-18T01:24:50Z

Content type: tutorial

Language: en

Sources: [Stories by Nav Singh 🇨🇦 on Medium](<https://devfeed.tech/sources/stories-by-nav-singh-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [properties](<https://devfeed.tech/topics/properties.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-2](<https://devfeed.tech/tags/kotlin-2.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [properties](<https://devfeed.tech/tags/properties.md>)

## AI overview

This tutorial explains Kotlin 2.3.20's experimental name-based destructuring declarations, which match variables to properties instead of relying on componentN() position. It also covers the compiler option and supported modes.

## Source excerpt

Image generated using Perplexity Name-based destructuring declarations were introduced in Kotlin 2.3.20 and match variables to properties rather than relying on position-based componentN(). Previously, destructive declarations used position-based destruction: data class User(var firstName: String, var lastName: String) val user = User("Alice", "Husseini") // componentN() val(firstName,lastName) = user println(firstName) println(lastName)Drawback of the componentN() based approach Destructuring relies on the order of componentN() functions, lastName receives the value of firstName, and firstName receives the value of lastName 👇 data class User(var firstName: String, var lastName: String) val user = User("Alice", "Husseini") // componentN() val(lastName,firstName) = user println(firstName) -> Husseini println(lastName) -> AliceName-based destructuring ✨ It's an Experimental feature. We can control how the compiler interprets destructuring declarations with the -Xname-based-destructuring compiler option. kotlin { // .. compilerOptions { freeCompilerArgs.add("-Xname-based-destructuring=only-syntax") } }Each variable refers to a property by name.val user = User("Alice", "Husseini") // Name-based destructuring (val firstName = firstName, val lastName = lastName) = userModeshttps://kotlinlang.org/docs/whatsnew2320.html#languageMode -- Name-Mismatch⚠ Warning ⚠Name-Mismatch warningMode -- Complete Position-based destructuring using square brackets []: data class User(var firstName: String, var lastName: String) val user = User("Alice", "Husseini") // componentN() val [firstName,lastName] = userReferences What's new in Kotlin 2.3.20 | Kotlin Stay in touch https://www.linkedin.com/in/navczydev/ JavaScript is not available. navczydev - Overview navczydev.bsky.social Beyond Positions: Kotlin's New Name-Based Destructuring was originally published in ProAndroidDev on Medium, where people are continuing the conversation by highlighting and responding to this story.