Parameters in Kotlin are always immutable. Marking a constructor parameter as a val turns it into a property of a class, and this can only be done in the primary constructor, because the set of properties of a class cannot vary depending on the constructor used to create an instance of the class.
↧
Answer by yole for Kotlin: 'val' on secondary constructor parameter is not allowed
↧