Jan Ouwens | @jqno
August 23rd, 2019
Future
is faster and more robustProcedure syntax
def m() { ... }
↓
def m(): Unit = { ... }
Unicode arrows
← → ⇒
↓
<- -> =>
Postfix operators
xs size
↓
xs.size
For simplicity, performance and safety
CanBuildFrom
Traversable
TraversableOnce
scala.Seq
is now immutable! 🎉
Deprecated /:
and :\
(use foldLeft
and foldRight
)
much, much more
more about that later
Using(new BufferedReader(new FileReader("file"))) { reader =>
// do stuff
}
reader.close()
called automatically
Useful for debugging
val result = ???
println(result)
result
↓
import scala.util.chaining._
result.tap(println)
"12".toIntOption → Some(12)
"nope".toIntOption → None
.right
is deprecated
Either is now right-biased
Recommended flags for 2.12 by tpolecat
Not all of them work
-Ywarn-inaccessible
→ -Xlint:inaccessible
-Yno-adapted-args
<artifactId>scalafmt-core_${scala.version}</artifactId>
↓
<artifactId>scalafmt-core_2.12</artifactId>
Scala-fmt is not available for 2.13 yet
But it doesn’t matter
array.map(...)
↓
array.toSeq.map(...)
Arrays are mutable
map
should not mutate in-place
import scala.collection.immutable.Seq
↓
nothing
🎉
import scala.collection.JavaConverters._
↓
import scala.jdk.CollectionConverters._
Java interop has moved
myMap.filterKeys(...)
myMap.mapValues(...)
↓
myMap.view.filterKeys(...)
myMap.view.mapValues(...)
They are implemented as views; this makes that explicit
Strict versions may come later
Stream.continually(...)
↓
LazyList.continually(...)
Stream
is deprecated because it was not fully lazy
Did you update?
4.0 is broken for us
¯\_(ツ)_/¯
≥ 3.0.8
import org.scalatest.prop.Checkers
↓
import org.scalatestplus.scalacheck.Checkers
ScalaCheck related classes have moved to ScalaTestPlus
Remove EitherValues
trait
e.right.value
↓
e.toOption.value
Because Either.right
is deprecated
≥ 3.3.2
java.time
VARCHAR
instead of TIMESTAMP
≥ 1.4.0
scoverage-maven-plugin
1.4.0 does not exist 😢
Fork this Pull Request
Measures differently: may need to adjust thresholds
Any
Now unusable due to so many false positives
StringPlusAny
Now also applies to string-interpolation!
Also, any2stringadd
is now deprecated in Scala anyway
Transitive dependencies may or may not be compatible
<exclusions>
<!-- pulls in Jackson for Scala 2.12 instead of 2.13,
so we have to suppress here -->
<exclusion>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.12</artifactId>
</exclusion>
</exclusions>
@jqno