Templates by BIGtheme NET

Scala

Overview of Collections

An Overview of the Collections API : 1) For instance, every kind of collection can be created by the same uniform syntax, writing the collection class name followed by its elements. Traversable(1, 2, 3) Iterable("x", "y", "z") Map("x" -> 24, "y" -> 25, "z" -> 26) Set(Color.red, Color.green, Color.blue) SortedSet("hello", "world") Buffer("x", "y", "z") IndexedSeq(1.0, 2.0) LinearSeq("a", "b", "c") 2) ...

Read More »

Mutable and Immutable Collections

Basics 1) By default, Scala always picks immutable collections. For instance, if you just write Set without any prefix or without having imported Set from somewhere, you get an immutable set, and if you write Iterable you get an immutable iterable collection, because these are the default bindings imported from the scala package. 2) To get the mutable default versions, ...

Read More »

Core – Scala’s Collections Library

Introduction 1) The usages of the collection operation make inputs and output explicit as function parameters and results. 2) These explicit inputs and outputs are subject to static type checking. The bottom line is that the large majority of misuses will manifest themselves as type errors. 3) Parallel collections support the same operations as sequential ones, so no new operations ...

Read More »

Scala Basics And Hello World Example

Basics 1) Scala integrates features of both object-oriented and functional programming. Scalability = Functional Programming + Objects 2) Scala has the same compilation model as Java and C#, namely separate compilation and dynamic class loading, so that Scala code can call Java libraries, or .NET libraries in the .NET implementation. To the JVM, Scala code and Java code are indistinguishable. ...

Read More »