Skip to content

Instantly share code, notes, and snippets.

@graven
Created April 12, 2010 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graven/363196 to your computer and use it in GitHub Desktop.
Save graven/363196 to your computer and use it in GitHub Desktop.
class Duple(val first : float, val second : float)
class DiagDuple(val sole : float) extends Duple(sole, sole)
class Ellipse[-F <: Duple](foci : F) {
private var m_foci : Duple = foci
def foci : Duple = m_foci
def foci_=(foci : F) = m_foci = foci
}
class Circle(center : DiagDuple) extends Ellipse[DiagDuple](center)
object MyApp extends Application {
def calcExc[T <: Duple](el : Ellipse[T]) = el.foci.first - el.foci.second
Console println calcExc(new Circle(new DiagDuple(42)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment