Linting rules
E001: field-init-can-be-folded
Checks for struct initialization where the field name and the variable used to initialize it are the same.
Metadata
Code:E001Rule:field-init-can-be-foldedStatus: Stable sincev0.0.1Quick fix: always available
What it does
Checks for struct initialization where the field name and the variable used to initialize it are the same.
Why is this bad?
It's redundant and can be simplified using the shorthand syntax.
Example
struct Foo { bar: int }
fun main() {
val bar = 1;
val foo = Foo { bar: bar };}Use instead:
struct Foo { bar: int }
fun main() {
val bar = 1;
val foo = Foo { bar };
}Last updated on