Basic Types and Literals
Numbers, booleans, and chars.
Scala's Basic Types
Scala ships with a small set of built-in value types you will use constantly.
Int,Longfor whole numbersDouble,Floatfor decimalsBoolean,Char,String
Each has a literal syntax for writing values directly in code.
Int Literals
A whole number with no decimal point is an Int by default, a 32-bit signed integer.
You can group digits with underscores for readability.
object Main extends App {
val year = 2026
val big = 1_000_000
println(year + big)
}All lessons in this course
- val vs var
- Basic Types and Literals
- Type Inference
- Expressions over Statements