Skip to content

Commit

Permalink
Merge pull request #1235 from eed3si9n/wip/recipe
Browse files Browse the repository at this point in the history
[2.x] Recipe for hello world
  • Loading branch information
eed3si9n authored Sep 19, 2024
2 parents 13db3fc + 8dfba13 commit 3482888
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/reference/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
- [Caching](concepts/caching.md)
- [Reference]()
- [Remote cache setup](reference/remote-cache-setup.md)
- [Recipes]()
- [Write hello world](recipes/hello-world.md)
- [Appendix]()
- [Setup notes](setup-notes.md)
42 changes: 42 additions & 0 deletions src/reference/recipes/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
How to write hello world
========================

Problem
-------

I want to write a hello world program in Scala, and run it.

Steps
-----

1. Create a fresh directory, like `hello_scala/`
2. Create a directory named `project/` under `hello_scala/`, and create `project/build.properties` with
```
sbt.version={{sbt_version}}
```
3. Under `hello_scala/`, create `build.sbt`:
```scala
scalaVersion := "{{scala3_example_version}}"
```
4. Under `hello_scala/`, create `Hello.scala`:
```scala
@main def main(args: String*): Unit =
println(s"Hello ${args.mkString}")
```
5. Navigate to `hello_scala/` from the terminal, and run `sbt`:
```bash
$ sbt
```
6. When the prompt appears, type `run`:
```scala
sbt:hello_scala> run
```
7. Type `exit` to exit the sbt shell:
```scala
sbt:hello_scala> exit
```

Alternatives
------------

When you're in a hurry, you can run `sbt init` in a fresh directory, and select the first template.

0 comments on commit 3482888

Please sign in to comment.