Monthly Archives: October 2010

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 … Continue reading

Posted in Scala Experience | Tagged , , , | Leave a comment

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 … Continue reading

Posted in Scala Experience | Tagged , | Leave a comment

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 = … Continue reading

Posted in Scala Experience | Leave a comment

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 … Continue reading

Posted in Scala Experience | Tagged , , , , , , | Leave a comment

Java example for Cloneable interface

//  Simple example which I found for cloneable and improve just to practise Java
// If you have some notes on my implementation I will be happy to hear them.
package cloneable;
// Refered object from class for cloning
class Department implements … Continue reading

Posted in Java Experience | Tagged , , | Leave a comment

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 … Continue reading

Posted in Scala Experience | Tagged , | Leave a comment