Scala

Scala

Made by DeepSource

Replace find() [==/!=] None with exists() SC-R1009

Anti-pattern
Minor

find() allows you to look for elements in a collection that satisfy the provided condition/predicate. However, if you only need to determine whether elements matching your predicate exist, it is suggested that you directly use exists() as it is slightly more efficient, readable, and easy to maintain.

Bad practice

if (nums.find(x => x % 5 == 0 && x >= 10) != None) {
  // ...
}

Recommended

if (nums.exists(x => x % 5 == 0 && x >= 10)) {
  // ...
}