Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 537 Bytes

EqualsNullCall.md

File metadata and controls

23 lines (14 loc) · 537 Bytes

Pattern: Use of equals() to compare value with null

Issue: -

Description

To compare an object with null prefer using ==. This rule detects and reports instances in the code where the equals() method is used to compare a value with null.

Example of incorrect code:

fun isNull(str: String) = str.equals(null)

Example of correct code:

fun isNull(str: String) = str == null

Further Reading