# Kotlin var with Read-Only Collections vs. val with Mutable Collections

DevFeed: [Kotlin var with Read-Only Collections vs. val with Mutable Collections](<https://devfeed.tech/articles/mutable-objects-or-properties-39391.md>)

Original publisher: [Read original article](<https://kt.academy/article/var_readonly_vs_val_mutable>)

Published: 2024-06-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Collections](<https://devfeed.tech/topics/collections.md>)

Tags: [atomic](<https://devfeed.tech/tags/atomic.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [collections](<https://devfeed.tech/tags/collections.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [memory](<https://devfeed.tech/tags/memory.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

## AI overview

This article compares Kotlin var properties holding read-only collections with val properties holding mutable collections. It explains trade-offs involving copying costs, observability, defensive copies, and thread safety, concluding that the preferable choice depends on how the state is accessed and modified.

## Source excerpt

Time to answer the question: var/readonly vs val/mutable. Which one should you use?