What are AnyVal.types for?

I accidentally wrote this line of code:

scala> val f = Int f: Int.type = object scala.Int 

Seems to work for every AnyVal subtype except AnyVal itself.

Is there anything I can use f for or is it just a detail of the Scala leak implementation?

+6
source share
1 answer

The companion Int object is described here . It does not give much, but here are a couple of things:

 scala> val f = Int f: Int.type = object scala.Int scala> f.MaxValue res1: Int = 2147483647 scala> f.box(2) res2: java.lang.Integer = 2 
+7
source

Source: https://habr.com/ru/post/897543/