'This' type

Adrian Kuhn akuhn at gmx.ch
Tue Mar 3 13:51:11 PST 2009


On Mar 3, 2009, at 21:17 , Marek Kozieł wrote:

> ALTERNATIVES:
> Rewriting each method's signature on every class / interface.

Using self-bound generics, such as

abstract class A<Self extends A<Self>> {
	abstract Self self();
}

class B extends A<B> {
	B self();
}

class C extends A<C> {
	C self();
}

This is used in java.lang.Enum for example.

See also http://www.artima.com/forums/flat.jsp?forum=106&thread=136394

--AA


More information about the coin-dev mailing list