Reputation: 25
I understand the difference between val and var in Scala. My question is would val be considered a type of variable, immutable type, in Scala still? Some online resources do consider val as different type of variable while others do not.
Upvotes: 0
Views: 378
Reputation: 51723
Types are Int
, String
, Boolean
, List[Double]
, ...
https://scala-lang.org/files/archive/spec/2.13/03-types.html
Value x
in val x: Int
and variable x
in var x: Int
are different "sorts" of identifiers with the same type Int
.
Upvotes: 4