case class Person(name : String, age : Int) val team = List(Person("Moni", 29), Person("Anna", 30), Person("Hannes", 40)); println(team.filter((p : Person) => p.age > 35)); println(team.filter(_.age > 35)); //shortcut println(team.map((p : Person) => p.name)); println(team.map(_.name)); //shortcut val wise = (p : Person) => p.age > 35; println(team.filter(wise));
Wednesday, September 26, 2012
Filter and Map
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment