Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Author(val company: String, val twitterHandle: String)
- def twitterHandles(authors: List[Author], company: String) = {
- authors.filter(_.company == company)
- .map(_.twitterHandle)
- .filter(_ != null)
- }
- def main(args: Array[String]) {
- val x = List(
- new Author("c1", "ct1"),
- new Author("c1", "ct2"),
- new Author("c2", "t3"),
- new Author("c1", null),
- new Author("c1", "ct5"),
- new Author("c5", "t6")
- )
- println(twitterHandles(x, "c1"))
- println(twitterHandles(x, "c2"))
- println(twitterHandles(x, "c00"))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement