Last active
December 18, 2015 15:09
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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