thanks Sean. I am cross posting on dev to see why the code was written that way. Perhaps, this.type doesn’t do what is needed.
Mohit Jaggi Founder, Data Orchard LLC www.dataorchardllc.com > On Aug 30, 2016, at 2:08 PM, Sean Owen <so...@cloudera.com> wrote: > > I think it's imitating, for example, how Enum is delcared in Java: > > abstract class Enum<E extends Enum<E>> > > this is done so that Enum can refer to the actual type of the derived > enum class when declaring things like public final int compareTo(E o) > to implement Comparable<E>. The type is redundant in a sense, because > you effectively have MyEnum extending Enum<MyEnum>. > > Java allows this self-referential definition. However Scala has > "this.type" for this purpose and (unless I'm about to learn something > deeper about Scala) it would have been the better way to express this > so that Model methods can for example state that copy() returns a > Model of the same concrete type. > > I don't know if it can be changed now without breaking compatibility > but you're welcome to give it a shot with MiMa to see. It does > compile, using this.type. > > > On Tue, Aug 30, 2016 at 9:47 PM, Mohit Jaggi <mohitja...@gmail.com> wrote: >> Folks, >> I am having a bit of trouble understanding the following: >> >> abstract class Model[M <: Model[M]] >> >> Why is M <: Model[M]? >> >> Cheers, >> Mohit. >> --------------------------------------------------------------------- To unsubscribe e-mail: dev-unsubscr...@spark.apache.org