Home / Companies / JetBrains / Blog / Post Details
Content Deep Dive

The Road to Name-Based Destructuring | The Kotlin Blog

Blog post from JetBrains

Post Details
Company
Date Published
Author
Alejandro Serrano Mena
Word Count
1,437
Company Posts That Month
76
Language
American English
Hacker News Points
-
Summary

Kotlin is undergoing a significant evolution in its approach to destructuring, shifting from a position-based to a name-based system. This change introduces new syntax options, such as using "val" inside parentheses for name-based destructuring and square brackets for positional destructuring, which are currently experimental and can be enabled with specific compiler arguments. The transition aims to address issues related to refactoring, abstraction, and inadvertent errors due to property order mix-ups, by ensuring that properties are accessed by their stable names rather than their order. The compiler provides migration tools and warnings to aid developers in adapting their code, and while name-based destructuring is set to become the default in future Kotlin versions, the plan includes a gradual rollout with substantial time for the community to adjust. This approach maintains backward compatibility with existing data classes while preparing for advanced features like multi-field value classes that will only support name-based destructuring.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Serverless 1 1,797 597 92 +165%