Found invalid annotation
@Deprecated()
, use @deprecated()
instead29
30 def readFile(path: String): String = Source.fromFile(path).mkString
31
32 @Deprecated()33 def cmpArray1(arr1: Array[Int], arr2: Array[Int]): Boolean = arr1 == arr2
34 def stringifyArray(arr: Array[Int]): String = arr.toString
35}
Description
Languages like Java and Scala allow you to annotate a method as deprecated
to signify that the method is no longer supported and will be dropped in the near future and that the users must switch to a suitable alternative. However, marking a Scala method with Java's annotation, i.e. @Deprecated
is not ideal. Rather, it is suggested that you use the Scala's annotation, i.e. @deprecated
as the former may or may not trigger the deprecated message.
Bad practice
@Deprecated()
def foo(): Unit = ???
Recommended
@deprecated()
def foo(): Unit = ???