Kotlin

Kotlin

Made by DeepSource

The property can be declared as const KT-P1001

Performance
Major
Autofix

In Kotlin, using const properties is preferred over regular properties for improved performance, efficiency, code clarity, and compile-time safety. const properties are evaluated at compile-time, leading to faster execution and eliminating the need for runtime initialization. const properties also enhance code readability and consistency by sharing the same constant value across all references. By utilizing const properties appropriately, one can achieve more efficient and clearer code in Kotlin.

Bad Practice

val myConstant = "abc"

Recommended

Instead, prefer declaring the property as a const val.

const val MY_CONSTANT = "abc"

Reference