Skip to content

Instantly share code, notes, and snippets.

@rbaron
Created August 31, 2015 18:32
Show Gist options
  • Save rbaron/0a3c86476228fcd14a40 to your computer and use it in GitHub Desktop.
Save rbaron/0a3c86476228fcd14a40 to your computer and use it in GitHub Desktop.
Type parameter question
trait Indiv[V <: Indiv[V]] {
val fitness: Double
def reproduce(other: V): V
}
class RealIndiv[V](override val fitness: Double) extends Indiv[V] {
override def reproduce(other: V) = new RealIndiv(fitness + other.fitness)
// ^ Cannot resolve symbol fitness (on `other.fitness`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment