What's different between “def apply[T](c:T)” and “type T;def apply(c:T)”
问题 I have this program: object B{ def apply[T](c:T)={} } object C{ type T def apply(c:T)={} } object A extends App{ val d=B{println(1);2} val e=C{println(1);2} } the line val e = C{println(1);2} told me error:Type mismatch,expected C.T,actual:2 so why can't I write type T def apply(c:T) it seems the same as apply[T](c:T) and what's the type of T when I write val d=B{println(1);2} I can write many lines here! because T means generic,so it can be Int,String,user defined class Apple,Orange... and