How can I indicate in an abstract class that the return value of a method is of the same type as the specific class that is a member?
For instance:
abstract class Genotype {
def makeRandom(): Genotype
def mutate(): Genotype
}
I would like to say that whenever you call mutate()in a particular Genotype class, you will definitely get another instance of the same Genotype class.
I would prefer not to use the type parameter in the view Genotype[SpecificGenotype259], since this type parameter can propagate throughout the code (it is also redundant and confusing). I would prefer to identify specific classes of genotypes, ranging from different traits.
source
share