|
|
|
|
|
by KMag
1864 days ago
|
|
Interesting, and I presume it works for singletons of any type, correct? val x: 1 = 1
val y: 2.718281828 = 2.718281828
That's kind of cute. I presume its main purpose is for overrides in order to get something similar to template specialization. C++ templates can be specialized by types and by values, but Scala method overrides are only by type, and literal types allow you to present a value as a type, so if the value can be statically proven to match, then the override is called? |
|