Scala

Scala

Made by DeepSource

Consider using the comparison operators == or != to compare Strings SC-R1026

Anti-pattern
Minor

Because comparison operators in languages like Java are usually used for reference equality checks, types such as String implement a method called .equals that allows you to check if two Strings are equal or not. However, Scala allows the user to perform value equality checks using the comparison operators as long as the object's class overrides the equals method. It is suggested that you use comparison operators instead of the .equals method when comparing 2 strings.

Bad practice

if (str1.equals(str2)) {
  // ...
}

Recommended

if (str1 == str2) {
  // ...
}