# Kotlin 2.4 Brings Swift-Style Collection Syntax \[\]

DevFeed: [Kotlin 2.4 Brings Swift-Style Collection Syntax \[\]](<https://devfeed.tech/articles/kotlin-2-4-brings-swift-style-collection-syntax-25983.md>)

Original publisher: [Read original article](<https://proandroiddev.com/kotlin-2-4-brings-swift-style-collection-syntax-0ab7097aa166?source=rss-711ab22c5c77------2>)

Author: Nav Singh

Published: 2026-06-04T16:32:23Z

Content type: article

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>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [Code](<https://devfeed.tech/topics/code.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [build](<https://devfeed.tech/tags/build.md>), [collection](<https://devfeed.tech/tags/collection.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-2](<https://devfeed.tech/tags/kotlin-2.md>), [kotlin-standard-library](<https://devfeed.tech/tags/kotlin-standard-library.md>), [new-features](<https://devfeed.tech/tags/new-features.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

This article explains Kotlin 2.4's experimental collection literals, which allow collections to be initialized with bracket syntax instead of functions such as listOf() or mutableListOf(). It also covers enabling the feature with the compiler option and discusses explicit declarations and type inference.

## Source excerpt

Image generated using Perplexity In Kotlin 2.4, collection literals are introduced, making collection initialization more concise and readable. To define collections, we no longer need to use functions like listOf() or mutableListOf(). This reduces boilerplate and makes intent clearer at a glance, especially when working with simple, static data. It's currently an experimental feature. We need to opt in, and the syntax or behavior may evolve in future releases. Add the Xcollection-literals compiler option to the build file kotlin { jvmToolchain(21) compilerOptions { freeCompilerArgs.add("-Xcollection-literals") } }Code samples Bracket syntax [] + explicit declaration // Mutable list with explicit type declaration // val plFNames: MutableList<String> = mutableListOf("Joe", "Alice") // Mutable list with brackets syntax val plFNames: MutableList<String> = ["Joe", "Alice"] println(plFNames) // ["Joe", "Alice" ] Bracket syntax [] + type inference As per docs:Compiler defaults to List if it lacks sufficient information to infer the collection type.But it seems like Array as we can see in the screenshot 📸 👇 val plFNames = ["Joe", "Alice"] println(plFNames) // ["Joe", "Alice" ]Screenshot type inference -- typeReferences What's new in Kotlin 2.4.0 | Kotlin Kotlin 2.4 Brings Swift-Style Collection Syntax [] was originally published in ProAndroidDev on Medium, where people are continuing the conversation by highlighting and responding to this story.