Scala Repl

Today I watched an screen cast of Dick Wall for Scala REPL. I think it's very interesting   for  every developer with interests in

Scala class examples

Notes on Scala's class : Parameters of Scala methods are values (val) not variables (var) Scala method returns the last value computed by the method //  Scala class with a private member class Shape{ private var vertexes = 0 } // Scala class with a method class Shape{ def draw() : Unit = { // Body of the method } } // Scala class with a method

Scala Map Examples

Notes on maps : - there is mutable and immutable maps Examples : import scala.collection.mutable.Map val rucksack = Map[Int, String]() rucksack += (1 -> shawl) rucksack += (2 ->gloves) rucksack += (3->hat) println(rucksack) val ruckSackPile = Map[Int, String](1 -> shawl, 2 ->gloves, 3->hat) println(ruckSackPile) Reference: 1. Programming in Scala: A Comprehensiv e Step-by-step

Scala Sets Examples

Notes on sets : - Scala provides mutable and immutable sets. (scala.collection.mutable, scala.collection.immutable ) Sets examples : - Sets creating, initializating scala> import scala.collection.mutable.Set scala> val teniscordVisitorsSet = Set(Players, Watchers) scala> tenisCordVisitorsSet += Referees scala>import scala.collection.immutable.HashSet scala>val tenisCordVisitorsSet = HashSet(Players, Watchers) Reference : 1.  Programming in Scala: A Comprehensiv e Step-by-step

Scala Tuples Examples

My notes on tuples : - tuples are immutable, but unlike lists, tuples can contain different types of elements - tuples are very useful when you need to return multiple objects Tuples examples : - Access to element of tuple scala > val pair = (99, Luftballons) scala > println(pair._1) scala > println(pair._2) Reference : 1. Programming in Scala: A Comprehensiv e Step-by-step

Scala List Examples

My notes on scala.lists : - scala.list is different from java.util.List - scala.list is  'immutable sequence of objects' - scala list doesn't support append operation Some Scala list operators and methods: ::: - for list concatenation scala > val oneTwo = List(1, 2) scala > val threeFour = List(3, 4) scala > val oneTwoThreeFour = oneTwo ::: threeFour :: - cons operator -

Arrays in Scala and its tricky behaviour ;-)

The row bellow shows parametrizing of an array with a String type in Scala. scala > val greetStrings = new Array[String](3) If I have to be honest it's very unclear what is the meaning of parametrizing of an array and why is not used the word definition  ;-). Every time when I read for Scala I

A little Scala Quiz ;-)

These two lines returns the same result. What is the name of the second line special shorthand ? 1) args.foreach( (arg : String) => println(arg)) 2) args.foreach(println) Response :  Partially applied function It can be used when a function literal consist of one statement that takes a single

Scala Variables

Last week I read about Scala's variable definition. I note an interesting way to define a variable which make me write this post.  Scala has two type of variables which can be defined with var and val. These key words shows how to use a variable. For example if we define variable with var

Hello World in Scala II ;-)

I did my brief research regarding Scala's object concept. The notion behind the key word object is that every element in Scala language is object even the primitive type int.  So there isn't even class level fields and methods. For example you can't implement Singleton design pattern or to use static methods and fields.