Skip to content

Files

Latest commit

 

History

History
19 lines (12 loc) · 606 Bytes

DataClassContainsFunctions.md

File metadata and controls

19 lines (12 loc) · 606 Bytes

Pattern: Data class with function

Issue: -

Description

Data classes should mainly be used to store data. This rule assumes that they should not contain any extra functions aside functions that help with converting objects from/to one another. Data classes will automatically have a generated equals, toString and hashCode function by the compiler.

Example of incorrect code:

data class DataClassWithFunctions(val i: Int) {
    fun foo() { }
}

Further Reading