Skip to content

Instantly share code, notes, and snippets.

Sample usage of flatMap to create a list of only results from values found in a Map ... More details at: http://sdanzig.blogspot.com/2013/06/the-option-design-pattern.html
Console.println("\nLast names for list of first names:")
Console.println(List("beth","sam","harry").flatMap(
firstToLastNameMap.get(_)).map("["+_+"]").mkString(","))
/*
Output:
Last names for list of first names:
[peterson],[smith]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment