Skip to content

Files

Latest commit

 

History

History
33 lines (22 loc) · 669 Bytes

WrongEqualsTypeParameter.md

File metadata and controls

33 lines (22 loc) · 669 Bytes

Pattern: Incorrect equals() type parameter

Issue: -

Description

Reports equals() methods which take in a wrongly typed parameter. Correct implementations of the equals() method should only take in a parameter of type Any?.

Example of incorrect code:

class Foo {

    fun equals(other: String): Boolean {
        return super.equals(other)
    }
}

Example of correct code:

class Foo {

    fun equals(other: Any?): Boolean {
        return super.equals(other)
    }
}

Further Reading