<:< operator in scala

前端 未结 7 1035
说谎
说谎 2020-11-29 21:34

Can anybody provide some details on <:< operator in scala. I think:

if(apple <:< fruit)  //checks if apple is a subclass of fruit.         


        
相关标签:
7条回答
  • 2020-11-29 22:27

    Hmm... I can't seem to find "<:<" anywhere as well, but "<:" denotes subtyping. From http://jim-mcbeath.blogspot.com/2008/09/scala-syntax-primer.html#types :

    List[T] forSome { type T <: Component }
    

    In the above example, we are saying T is some type which is a subtype of Component.

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