Skip to content

scala

Add SBT wrapper to a project

This tutorial will show how to add SBT wrapper to a project, so we don’t have to install either Sbt or Scala in order to build it.

Similarly to Gradle Wrapper, SBT users also have the ability to add a wrapper to their projects, thanks to the excellent sbt-extras project maintained by a group of more than 50 contributors up to this date. This project provides a sbt bash script that works similarly to gradlew for Gradle projects.

According to the documentation, the script will automatically detect and download the required Scala and Sbt versions on runtime. This means you can work on multiple projects with different version combinations without having to update your environment settings.

Read More »Add SBT wrapper to a project

Scala: scala.util.Try

The type scala.util.Try is an operation that may result in either an exception or a valid output. Let’s explore a few of its usages, including single and chained calls to scala.util.Try.

The Try operation will result in either a Success or Failure. To simplify, think about it an Either for successes and failures instead of Left and Right, but proper for encapsulating exceptions instead of other arbitrary values.

Read More »Scala: scala.util.Try

Scala: access modifiers

Scala access modifiers

Scala provides a more granular access control if compared to Java. This post describes and shows how to implement each of the Scala access modifiers.

Access modifiers

Scala has only two explicit access modifiers: private and protected, besides the implicit no modifier that defaults to public access.

However, we can qualify these modifiers to give them a finer-grained access control level.

Read More »Scala: access modifiers