scala-lang.org - The Scala Programming Language

Example domain paragraphs

New on the blog: sbt Plugins Community Repository

Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries.

val fruits = List ( "apple" , "banana" , "avocado" , "papaya" ) val countsToFruits = // count how many 'a' in each fruit fruits . groupBy ( fruit => fruit . count ( _ == 'a' )) for ( count , fruits ) <- countsToFruits do println ( s "with 'a' × $count = $fruits" ) // prints: with 'a' × 1 = List(apple) // prints: with 'a' × 2 = List(avocado) // prints: with 'a' × 3 = List(banana, papaya) High-level operations avoid the need for complex and error-prone loops.

Links to scala-lang.org (315)