Skip to content

Instantly share code, notes, and snippets.

@mctigger
Created June 19, 2015 15:33
Show Gist options
  • Save mctigger/b5c1408c8e5cea48f044 to your computer and use it in GitHub Desktop.
Save mctigger/b5c1408c8e5cea48f044 to your computer and use it in GitHub Desktop.
object BugFixProject {
def main (args: Array[String]) {
val repoWithEntities = Seq(
(ARepo, Seq(A("", ""), A("", ""))),
(BRepo, Seq(B("", ""), B("", "")))
)
printall(repoWithEntities)
}
def printall[Entity](pairs: Seq[(BaseRepo[Entity], Seq[Entity])]) : Seq[String] = {
pairs.map { t =>
val repo = t._1
val entities = t._2
entities.map(repo.toString(_))
}.flatten
}
}
case class A(foo: String, bar: String){}
case class B(foo: String, bar: String){}
trait BaseRepo[X] {
def toString(x: X) : String = x.toString
}
object BRepo extends BaseRepo[B] {}
object ARepo extends BaseRepo[A] {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment