So, the random question of the day. If you have an...
# random
r
So, the random question of the day. If you have an inline constructor the class member properties go below it (there's no other option). If you have multiple constructors though, do you declare the variables above the constructors (Java-style) or below? What's the "proper" Kotlin way?
r
https://kotlinlang.org/docs/coding-conventions.html
The contents of a class should go in the following order:
1. Property declarations and initializer blocks
2. Secondary constructors
3. Method declarations
4. Companion object
💯 1
l
Actually since kotlin property is technically not a field, it is indeed more flexible. I'd only declare properties that are widely used inside or outside the class right on the start, but group other more specific properties with the related functions. So you can say that there isn't a fixed pattern that secondary constructors and properties in the class block are positioned if you think this way. Also there are a lot of times I find public api first declaring secondary constructors for kind of constructor grouping, and then extra properties as well as init blocks, so I'm not sure if it's really a Kotlin Style thing.