Scala map implicit conversion into Java Properties
As it looks that there's no implicit conversion of a Scala Map (of Strings) into a Java Properties even in the latest Scala release, let's define one.
Or even in a one line fashion, using folding :
CONTEXT : Linux Gentoo / Scala 2.9.1 / Java 1.6.0_26
implicit def map2Properties(map:Map[String,String]):java.util.Properties = {
val props = new java.util.Properties()
map foreach { case (key,value) => props.put(key, value)}
props
}
Or even in a one line fashion, using folding :
implicit def map2Properties(map:Map[String,String]):java.util.Properties = {
(new java.util.Properties /: map) {case (props, (k,v)) => props.put(k,v); props}
}
CONTEXT : Linux Gentoo / Scala 2.9.1 / Java 1.6.0_26