Prerequisite
Install JDK in your system.
Step 1: Go to below location and download scala binaries.
https://www.scala-lang.org/download/ (or) https://github.com/lampepfl/dotty/releases
Step 2: Extract the downloaded binaries in step1.
Step 3: Set the variable SCALA_HOME to the path where Scala is extracted.
Set Scala bin directory path to your system path. Open new terminal and execute below command.
export PATH=$PATH:$SCALA_HOME/bin
Step 4: Execute the command ‘scala’. It opens scala REPL (Read-Evaluate-Print-Loop) prompt.
$scala
Welcome to Scala 2.13.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_251).
Type in expressions for evaluation. Or try :help.
scala>
You can evaluate expressions at scala REPL prompt.
scala> 1 + 2
val res0: Int = 3
scala> 20 + 30
val res1: Int = 50
Similarly you can print data to console using the print function.
scala> print("Hello World")
Hello World
Execute the command :quit to come out of scala REPL prompt.
No comments:
Post a Comment