Skip to content

Instantly share code, notes, and snippets.

@daveshah
Created July 31, 2015 10:28
Show Gist options
  • Save daveshah/798eabdfe42dc2c268e7 to your computer and use it in GitHub Desktop.
Save daveshah/798eabdfe42dc2c268e7 to your computer and use it in GitHub Desktop.
case class Person(id: Int,firstName: String, lastName: String)
object PersonRepository {
private val people = Map(
1 -> Person(1,"Shah","Dave"),
2 -> Person(2,"Barington","Foo")
)
def findByIds(ids: List[Int]) : List[Option[Person]] = {
ids.map(id => people.get(id))
}
}
val peeps = PersonRepository.findByIds(List(1,2,3))
peeps.foreach(peep => println(peep))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment