Go to the video, er, spec 12.2:
Value classes are classes whose instances are not represented as objects of the underlying operating system. All value classes inherit from class AnyVal.
So, maybe the question is, if everything is an object, why does it bother me if something is not represented, for example, implemented as an object? This is described in detail in the implementation.
But don't let it pretend, of course, you don't care. Do you never specialize?
The spectrum continues:
Scala implementations need to provide the value classes Unit, Boolean, Double, Float, Long, Int, Char, Short, and Byte (but are available for others).
Therefore, the AnyVal test makes sense, in addition to listing the required value classes.
However, you must accept @drexin's answer, because if you do not use value classes for extension methods, then you really do not live. (I mean, living it.)
Motivation from SIP:
... classes in Scala that can be fully nested, so operations with these classes have zero overhead compared to external methods. Some for individual classes:
- Nested implicit wrappers. The methods of these wrappers will be translated into extension methods.
- New number classes such as unsigned ints. Will no longer be for such classes should be overhead boxes. So it looks like a class in .NET.
- Classes representing units of measure. Again, boxing overhead will be incurred for these classes.
You can mark the extension method itself as @inline, and everything is included: no object wrapper and your little method are built-in.
I use this feature every day. Yesterday I hit him. The error has already been fixed. What this says is that such a wonderful feature, Scala people will spend time on Coursera to undo a small mistake.
It reminds me, I forgot to ask, this is not a question from the Coursera survey, is it?