One interesting feature that was added to Scala in version 2.8 is specialization, using the @specialized annotation. First, a little background information. Generics in Java and the JVM, and consequently also in Scala, are implemented by using type erasure. That means that if you have an instance of a generic class, for example List[String], then [...]
Archive of posts filed under the Language features category.
A generic interpolate method using type classes
Writing a generic interpolate method; it doesn’t work with structural types, but it does with type classes.
Strange limitation when importing from different scopes
Scala has a strange limitation when importing methods with the same name from different scopes – a bug in the compiler that won’t be fixed soon.
Avoid structural types when pimping libraries
Methods in structural types are called via reflection, which is a lot slower than normal method calls. This can make “Pimp My Library” functions slow.
Converting an Option[A] to an Option[B]
How to convert an Option holding one type to an Option holding another type by using the collect method.