What does the “extends {..}” clause in Scala object definition, without superclass name, do?

前端 未结 1 497
醉梦人生
醉梦人生 2021-01-18 08:10

I found this code example in Programming in Scala, 2nd Ed. (Chapter 25, Listing 25.11):

object PrefixMap extends {
  def empty[T] = ...

  def apply         


        
相关标签:
1条回答
  • 2021-01-18 08:43

    Looks like a print error to me. It will work all the same, though, which probably helped hide it all this time.

    Anyway, that object is extending a structural type, though it could also be an early initialization, if you had with XXX at the end. MMmmm. It looks more like an early initialization without any class or trait to be initialized later, actually... structure types do not contain code, I think.

    0 讨论(0)
提交回复
热议问题