Tutorial by Examples

val and var scala> val a = 123 a: Int = 123 scala> a = 456 <console>:8: error: reassignment to val a = 456 scala> var b = 123 b: Int = 123 scala> b = 321 b: Int = 321 val references are unchangeable: like a final variable in Java, once it has been initial...
Let's pick as an example a function that takes 2 Map and return a Map containing every element in ma and mb: def merge2Maps(ma: Map[String, Int], mb: Map[String, Int]): Map[String, Int] A first attempt could be iterating through the elements of one of the maps using for ((k, v) <- map) and so...

Page 1 of 1