yoeo / scala-explained

Scala explained with code snippets

Home Page:https://scalaexplained.github.io/scala-explained/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scala explained

Scala is a programming language that let you write cool stuff like:

def sing(i: Int) = s"Happy Birthday ${ if (i == 3) "dear Tom" else "to You" }"
(1 to 4).map(sing).foreach(println)
/* -->
Happy Birthday to You
Happy Birthday to You
Happy Birthday dear Tom
Happy Birthday to You
*/

This website explains Scala features that will help you understand Scala programming. Each explanation is illustrated by a code snippet that can be copy-pasted into a Scala interpreter.

Talking about a Scala interpreter, here's how you can set up Scala programming tools:

Setup Scala environment

  1. Install Scala from the official website: https://www.scala-lang.org/download/

  2. Create a Scala source code file named MyScalaProgram.scala with the following content:

object MyScalaProgram {
  // the `main` method is the program entry point
  def main(args: Array[String]): Unit =
    println("I was here.")
}
  1. Compile and run your Scala program using your favorite Scala environment (IntelliJ, sbt) or through a terminal:
scala MyScalaProgram.scala
# --> I was here.

Start!

First of all, we will talk about Scala basic syntax.

If you are already familiar with Scala, you can learn more about Scala cool functional programming (FP) features here.

If you want to build beautiful software architectures, you can take a look at Scala mind blowing object concepts.

For the most curious among you, there is also an exhaustive list of Scala keywords and symbols with plenty of examples.

Enjoy.

About

Scala explained with code snippets

https://scalaexplained.github.io/scala-explained/