sbtのインストール
MacOSでは、Scalaプログラムを手動でコンパイルすることは非常に稀で、sbtという標準的なビルドツールを用いていること多いです。ここでは、まずsbtをインストールします。
Homebrewを用いてsbtをインストルします。
brew install sbt
# インストール済の情報
==> Downloading https://github.com/sbt/sbt/releases/download/v1.2.8/sbt-1.2.8.tgz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/279553/ae845a00-0be0-11e9-99d2-03a5afa9f1c7?X-Amz-Algorithm=AWS4-HMAC-SHA2
######################################################################## 100.0%
==> Caveats
You can use $SBT_OPTS to pass additional JVM options to sbt.
Project specific options should be placed in .sbtopts in the root of your project.
Global settings should be placed in /usr/local/etc/sbtopts
==> Summary
🍺 /usr/local/Cellar/sbt/1.2.8: 521 files, 50MB, built in 58 seconds
- sbtの場所: /usr/local/Cellar/sbt/1.2.8
REPLとsbt
これからしばらく、REPL(Read Eval Print Loop)機能と呼ばれる対話的な機能を用いてScalaプログラムを試して見ますが、それは常にsbt consoleコマンドを経由して行います。
# sbt consoleを起動
sbt console
scala> println("hello scala!")
hello scala!
ここまでは、scalaのインストールが完了です。
scalaを終了したい場合は、以下のコマンドで
scala> :quit