Getting Started

https://docs.scala-lang.org/getting-started/index.html

We recommend using the Scala installer tool “Coursier” that automatically installs all the requirements, but you can still manually install each tool.

Install

brew install coursier/formulas/coursier && cs setup

만약에 위의 명령어로 설치 후에도 sbt 명령어 사용시에, sbt not found에러가 뜨면,

brew insall sbt로 추가 설치 해주기

Create a “Hello World” project with sbt

sbt is a build tool for Scala. sbt compiles, runs, and tests your Scala code. (It can also publish libraries and do many other tasks.)

  1. cd to an empty folder.
  2. Run the command sbt new scala/scala3.g8 to create a Scala 3 project, or sbt new scala/hello-world.g8 to create a Scala 2 project. This pulls a project template from GitHub. It will also create a target folder, which you can ignore.
  3. When prompted, name the application hello-world. This will create a project called “hello-world”.
  4. Let’s take a look at what just got generated:
hello-world 
	- project (sbt uses **this** **for** its own files) 
		- build.properties 
	- build.sbt (sbt's build definition file) 
	- src 
		- main 
			- scala (all of your **Scala** code goes here) 
				- **Main**.scala (**Entry** point of program) <-- **this** is all we need **for** now

→ 나는 sudo 로 해주어야 프로젝트가 생성되었다.

Using VSCode with metals