Search code examples
scalatypessyntaxlanguage-design

Any reason for having "val capacity : Int" instead of "val Int Capacity" in Scala


I am reading Scala and I am wondering ...
Why

val capacity : Int 

instead of

val Int capacity.

Any reason why this choice was made. If not, it does not seem to me like a good choice to move away from the Java way of declaring it. Would have made the transition from Java to Scala easier (not by much, but little bit)


Solution

  • Because the majority of the time you can leave off the Int part. Scala has a much neater system of type inference than Java does.