sudo apt-get install openjdk-8-jdk
Follow the installation instructions on http://www.scala-sbt.org/release/docs/Setup.html
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt
Test installation by running sbt about
.
- To run REPL (Run - Evaluate - Print - Loop), furst run
sbt
than execute theconsole
command. Finish REPL withCtrl-D
. - To end sbt, use
exit
command orCtrl-D
.
-
Download from https://www.jetbrains.com/idea/download/ and unpack. See also [https://www.jetbrains.com/help/idea/2016.2/installing-and-launching.html#d1877341e227](Starting IntelliJ IDEA on Linux):
mkdir apps cd apps tar xvzf ~/Downloads/ideaIC-2016.2.4.tar.gz cd idea-IC-162.2032.8/bin ./idea.sh
-
Install Scala Plugin
-
Select JVM as default VM
// Definition
def x = 3 //> x : => Int
def y = 7 //> y : => Int
def z = x * y //> z : => Int
z //> res0: Int = 21
// Definition can have parameters (function)
def increase(i: Int) = i + 1
// Function result type can be defined
def increase(i: Int):Int = i + 1
Primitive types
aa | bbb |
---|---|
Int | 32 bit integer |
Double | 64 bit integer |
Boolen | true or false |
// Primitive
// Function can have multiple parameters and call other functions
def square(x: Double) = x * x
def sumOfSquares(x: Double, y: Double) = square(x) + square(y)