Skip to content

Files

Latest commit

 

History

History
25 lines (16 loc) · 550 Bytes

UseAnyOrNoneInsteadOfFind.md

File metadata and controls

25 lines (16 loc) · 550 Bytes

Pattern: Use of find instead of any/none

Issue: -

Description

Turn on this rule to flag find calls for null check that can be replaced with a any or none call.

Example of incorrect code:

listOf(1, 2, 3).find { it == 4 } != null
listOf(1, 2, 3).find { it == 4 } == null

Example of correct code:

listOf(1, 2, 3).any { it == 4 }
listOf(1, 2, 3).none { it == 4 }

Further Reading