Tuesday, October 20, 2015

Scala annotations

object Example1 {
//  @deprecated def bigMistake = {
//    println("Mistake.")
//  }

  // warning: match may not be exhaustive.
//  true match {
//    case true => true
//  }

  // no warning now
  (true: @unchecked) match {
    case true => true
  }

  // custom annotations
  import annotation._
  class strategy(arg: Annotation) extends Annotation
  class delayed extends Annotation
  @strategy(new delayed) def f() {}

}

0 comments: