Introduction to Scala
David Venturi
Curriculum Manager, DataCamp
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.
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.
scala.Doublescala.Floatscala.Longscala.Intscala.Shortscala.Bytescala.Charscala.Booleanscala.Unitjava.lang.Doublejava.lang.Floatjava.lang.Longjava.lang.Integerjava.lang.Shortjava.lang.Bytejava.lang.Characterjava.lang.BooleanType: restricts the possible values to which a variable can refer, or an expression can produce, at run time
Compile time: when source code is translated into machine code, i.e., code that a computer can read
Run time: when the program is executing commands (after compilation, if compiled)
A language is statically typed if the type of a variable is known at compile time. That is, types checked before run-time.
A language is dynamically typed if types are checked on the fly. That is, types are checked during execution (i.e., run time).
: Int in val fourHearts: Int = 4)scala> val fourHearts: Int = 4
fourHearts: Int = 4
scala> val fourHearts = 4
fourHearts: Int = 4
scala> val players: Array[String] = Array("Alex", "Chen", "Marta")
players: Array[String] = Array(Alex, Chen, Marta)
scala> val players = Array("Alex", "Chen", "Marta")
players: Array[String] = Array(Alex, Chen, Marta)
Introduction to Scala