Skip to content

Instantly share code, notes, and snippets.

@jamesgolick
Created March 19, 2010 15:31
Show Gist options
  • Select an option

  • Save jamesgolick/337608 to your computer and use it in GitHub Desktop.

Select an option

Save jamesgolick/337608 to your computer and use it in GitHub Desktop.
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)
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