Created
October 28, 2011 10:24
-
-
Save mads-hartmann/1322034 to your computer and use it in GitHub Desktop.
wish you could use extractors in arguments in scala
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
(for { | |
x <- 0 to 10 | |
} yield (42 -> x)).foldLeft(HashMap[Int,HashSet[Int]]()) { | |
(acc,current) => | |
val (y,z) = current | |
acc.updated(y, acc.getOrElse(y, HashSet[Int]()) + z) | |
} | |
// I wish the folding function could be defined like this | |
// | |
// (acc, (y,z)) => acc.updated(y, acc.getOrElse(y, HashSet[Int]()) + z) | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just slap a case in there: