Created
June 23, 2011 21:58
-
-
Save x3ro/1043741 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
import scala.collection.mutable._ | |
class Foo { | |
} | |
object Foo { | |
trait Transform[-A >: B, B, +R[_] <: Set[_]] { | |
def apply(a: A) : R[B] | |
} | |
class Person(val name: String) | |
case class Student(override val name: String, val matrNum: Int) extends Person(name) { | |
def rev = Student(name, matrNum.toString().reverse.toInt) | |
} | |
class PersToStud extends Transform[Person,Student,HashSet] { | |
def apply(a:Person):HashSet[Student] = a match { | |
case x:Student => HashSet(x.rev) | |
case _ => HashSet() | |
} | |
} | |
def main(args:Array[String]) { | |
var pts: Transform[Student,Student,Set] = new PersToStud | |
println(pts(new Student("julia",1234))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment