Doing JetBrains Basic Kotlin and it does not like ...
# getting-started
b
Doing JetBrains Basic Kotlin and it does not like the formatting of the first 3 val statement.
Copy code
fun main() {
    val min_sleep: Int = readln().toInt()
    val max_sleep: Int = readln().toInt()
    val hours_slept: Int = readln().toInt()

    println(
        if (hours_slept < min_sleep) {
            "Deficiency"
        } else if (hours_slept > max_sleep) {
            "Excess"
        } else {
            "Normal"
        }
    )
}
Variable names should match the pattern: [a-z][A-Za-z0-9]* What am I missing?
k
it doesn't like the underscores
minSleep
r
Use "camel case" for variable names (minSleep).
b
OK, thanks, just worked that out. A real shame, I find it a little less readable.
v
You can use any code style you want. snake_case is just not common for variable names in Kotlin (or also Java), so your code will look alien to any Kotlin or Java developer out there.
Most important is, that you are consistent within the same codebase
j
and you can disable this inspection if you want
it could be useful if you are using underscores everywhere
j
But your code will use external libraries (at least the Kotlin standard lib), which doesn’t use underscores. So using them, even consistently, within your code base will still make it an inconsistent mess. Just get into the habit of using the standard naming conventions.