There's a LOT to the Scala programming language. This project includes some common and useful libraries and techniques.
How do I... | Examples |
---|---|
compile and run scala code dynamically (eval)? | com.skraba.byexample.scala.dynamic |
use self-types versus traits? | TraitSelfTypeSpec |
use Regex? | Markd (A simple markdown parser) |
Some of the code samples were taken or adapted into unit tests from other learning resources. All of these are highly recommended!
Source | Examples |
---|---|
Official Tour of Scala | com.skraba.byexample.scala.tour |
Scala collections overview | com.skraba.byexample.scala.collections |
ScalaTest overview | com.skraba.byexample.scala.scalatest |
Other useful resources to learn more about Scala and functional programming:
This project includes an example executable that does a simple hello world mixing Java and Scala code.
mvn package
# Using the uber jar from the command line
alias byexample_go_scala="java -jar $(find ~+ -name scala-by-example-*.jar)"
byexample_go_scala --help
# Using the maven-generated classpath
mvn exec:java -Dexec.args="--name=World --count=7"
mvn exec:java -Dexec.mainClass="com.skraba.byexample.scala.ScalaGo" -Dexec.args="--name=world --count=7"
# MarkdGo is another internal application to this project.
alias byexample_go_markd="java -classpath $(find ~+ -name scala-by-example-*.jar) com.skraba.byexample.scala.markd.MarkdGo"
byexample_go_markd beautify readme.md
byexample_go_markd beautify $(find . -name \*.md)
By default, all of the slow tests (tagged with org.scalatest.tags.Slow
) are excluded, but you can run them using the command line:
mvn package -Dplugin.maven.scalatest.exclude=
Or by updating the default property in your pom.xml
:
<properties>
<plugin.maven.scalatest.exclude>org.scalatest.tags.Slow</plugin.maven.scalatest.exclude>
</properties>
In an IDE like IntelliJ, set the Program arguments in the Run/Debug Configuration to -l org.scalatest.tags.Slow
to exclude slow tests.