Scala

Function Currying in Scala

       One of the good feature that Scala Supports is function Currying (this concept is taken from Haskell). This feature is least used during Application Development. Now lets explore what is Currying Actually with an example……… scala> def mul(x:Int, y:Int):Int = x*y mul: (x: Int, y: Int)Int  scala> mul(2,4) res30: Int = 8… Continue reading Function Currying in Scala

Scala

Sets in Scala with examples

Sets are immutable by default in scala. if you to be mutable set then you need to explicitly create them using the fully qualified package like below scala.collection.mutable.Set[String] The  differences between List and Set are Lists are ordered and can allow duplicate elements as well Sets are not ordered and will no allow duplicate element… Continue reading Sets in Scala with examples

Scala

Scala Collections Package Hierarchy

The following figure shows all collections in package scala.collection. These are all high-level abstract classes or traits, which generally have mutable as well as immutable implementations. The following figure shows all collections in package scala.collection.immutable The following figure shows all collections in package scala.collection.mutable              All collection classes are found in the package scala.collection or… Continue reading Scala Collections Package Hierarchy

Scala

Methods of List Object in Scala

Creating lists from their elements: List.apply A literal like List(1, 2, 3) is simply the application of the object List to the elements 1, 2, 3. That is, it is equivalent to List.apply(1, 2, 3): scala>List.apply(1, 2, 3) res53: List[Int] = List(1, 2, 3) Creating a range of numbers: List.range scala>List.range(1,10) res37: List[Int] = List(1,… Continue reading Methods of List Object in Scala

Scala

Lists in Scala with examples

Scala Lists are always immutable and dynamically growable (but arrays are fixed in Scala once you create with some size ). If you want Mutable List then prefer to use ListBuffer(it is in scala.collection.mutable  package). Here will see about creation of List and operations on it. Different ways of Creating a List : Val samplelist… Continue reading Lists in Scala with examples