Quantcast
Viewing all articles
Browse latest Browse all 31

How to override Scala's default numeric type when defining a field

Scala FAQ: How do I override the default numeric type that Scala assigns when I declare an Int, Long, Short, Float, or Double val or var field?

Solution

If you assign 1 to a variable, Scala assigns it the type Int:

read more


Viewing all articles
Browse latest Browse all 31

Trending Articles