Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Scala Dojo September 2012
sealed trait JItem
type JMap = scala.collection.immutable.HashMap[String, JItem]
case class JInt(data: Int) extends JItem
case class JMapAsItem(val data: JMap) extends JItem
// ToDo: read about "implicit not found"
implicit def jmapAsItem2JMap(jmap:JMapAsItem):JMap =
implicit def jmap2JMapAsItem(jmap:JMap):JMapAsItem = JMapAsItem(jmap)
implicit def int2JInt(i: Int): JInt = JInt(i)
implicit def jInt2Int(ji:JInt):Int =
val m:JMap = new JMap();
val m2:JMap = new JMap();
val m3:JMap = m2+("a" -> m)
val m4:JMap = m3 + ("b" -> 5)
println("hello world "+m4)
//val m5:JMap = m4 + ("c" -> "string")
def sum(jmap: JMap) = {
jmap.values.foldRight(first, second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.