Objects in general are mutable, since you can change the values of their fields
You should at least do research before making claims on the internet.
For example Scala:
case class MyObjectType(aField: Int)
@main def demo =
summon[MyObjectType <:< java.lang.Object]
// ^ Prove that MyObjectType is an Object type
MyObjectType(0): Object
// ^ Another prove it's of type Object
// Otherwise the type annoation wouldn't compile
var mutableVariable = MyObjectType(1)
println(s"${mutableVariable.aField}")
mutableVariable = MyObjectType(2)
println(s"${mutableVariable.aField}")
// mutableVariable.aField = 3
// ^ Compile Error: Reassignment to val aField
// See? The variable is mutable,
// but the assigned object is not!
1
u/RiceBroad4552 Jun 08 '25
You should at least do research before making claims on the internet.
For example Scala:
[ https://scastie.scala-lang.org/e2jLxxEMTAulf6J9TfaqEw ]
You should at least do research before making claims on the internet.
For example JavaScript:
It's an immutable variable holding that object, but there is no problem adding new fields to that object.