danfran
9/19/2016 - 3:46 PM

Scala Tips

Scala Tips

Scala Tips

Template for generic method

def readValue[T:ClassTag](s:String):T = {
  val tClass = implicitly[ClassTag[T]].runtimeClass
  //implementation for different classes.
}

val myDouble = readValue[Double]("1.0")

Avoiding cast-check

someCollection.filter(_.isInstanceOf[Foo]).asInstanceOf[List[Foo]]

use

someCollection.collect(case c: Foo => c)

Sbt tree dependencies

sbt "inspect tree clean"

Sbt skip tests during assembly

sbt 'set test in assembly := {}' clean assembly