I found this sample code in a Program in Scala, 2nd Ed. (Chapter 25, listing 25.11):
object PrefixMap extends { def empty[T] = ... def apply[T](kvs: (String, T)*): PrefixMap[T] = ... ... }
Why is there an extends clause without a superclass name? This is like extending an anonymous class, but for what purpose? The accompanying text does not explain or even mention this construction anywhere. The code really compiles and seems to work just fine with or without it.
OTOH I found the same code on several web pages, including this one (which looks like the original version of a chapter in a book), I doubt that a typo could go below the radars of so many readers so far ... so I'm not enough?
I tried to do this, but struggled to find the right search terms. So can anyone explain if this construct has a name and / or practical use in Scala?
source share