Reputation: 1027
I am following this official code style guide for Kotlin (link goes to the section in particular): https://kotlinlang.org/docs/coding-conventions.html#property-names
This is my first time following a Code Style guide, so I want to verify, are they saying that all variable names that aren't immutable should be in UpperCamelCase?
The second example shows a mutable list, so I assumed that it is only for variables that hold array like data.
So my conclusion was that I should use the third example's UpperCamelCase for all regular variable names, like a findViewById<Button>
val.
What I assumed seems wrong, so is it the LowerCamelCase for such variables given in the second example? And only special objects get UpperCamelCase? I am asking for simple things like findViewById<Button>
, Strings, Ints, Booleans, etc.
Upvotes: 2
Views: 1116
Reputation: 321
I think you made a confusion reading the documentation. But to clarify:
SCREAMING_SNAKE_CASE
UpperCamelCase
lowerCamelCase
So for your cases of findViewById, Strings, Ints, Booleans (since your Strings and Ints aren't constants), then you should use lowerCamelCase
.
Upvotes: 5