Quantcast
Channel: Kotlin: 'val' on secondary constructor parameter is not allowed - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by yole for Kotlin: 'val' on secondary constructor parameter is not allowed

$
0
0

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.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>