Created
March 19, 2010 15:31
-
-
Save jamesgolick/337608 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| implicit def columnMap2Map[A, B](map: Map[Array[Byte], Array[Byte]]) | |
| (implicit f: Array[Byte] => A, g: Array[Byte] => B): Map[A, B] = { | |
| map.foldLeft(Map[A, B]()) { case(map, (k, v)) => | |
| val tuple = (k: A, v: B) | |
| map + tuple | |
| } | |
| } | |
| implicit def byteArray2UUID(bytes: Array[Byte]): UUID = UUID.valueOf(bytes) | |
| implicit def byteArray2String(bytes: Array[Byte]): String = new String(bytes) | |
This file contains hidden or 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
| val map: Map[org.safehaus.uuid.UUID, String] = test //this fails with error: no implicit argument matching parameter type (Array[Byte]) => B was found. | |
| val map: Map[org.safehaus.uuid.UUID, String] = columnMap2Map(test) // this works fine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment