Skip to content

@nirth /json_typesafe.scala
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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 = jmap.data
implicit def jmap2JMapAsItem(jmap:JMap):JMapAsItem = JMapAsItem(jmap)
implicit def int2JInt(i: Int): JInt = JInt(i)
implicit def jInt2Int(ji:JInt):Int = ji.data
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.