I've accidentally written this line of code:
scala> val f = Int
f: Int.type = object scala.Int
Seems开发者_StackOverflow社区 to work for every subtype of AnyVal
except for AnyVal
itself.
Is there anything I can use f
for or is it just an implementation detail of Scala leaking out?
The Int
companion object is documented here. It doesn't provide a lot, but here are a couple 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
精彩评论