Created
April 12, 2010 01:54
-
-
Save graven/363196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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