Data classes: Immutable?

Hi!

I am new to Kotlin and I just came across the data class functionality. I have seen mentions of “mutable” and “immutable” data classes. Sometimes it is a little contradictory. Here are some questions:

  1. Is a data class is meant to hold immutable data?
  2. If 1. is true, then why can we create a data class with mutable attributes?Example (no warnings or compiling errors here):

data class MyDataClass (var myMap : MutableMap<String,String>) 

If you happen to have a link to the documentation that explains the correct usage and you want to share it, I would appreciate it!

Thanks in advance! 😀

submitted by /u/daniagudelos
[link] [comments]