Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Last active August 29, 2015 14:16
Show Gist options
  • Save wrobstory/79872b94f0d7bf1720f1 to your computer and use it in GitHub Desktop.
Save wrobstory/79872b94f0d7bf1720f1 to your computer and use it in GitHub Desktop.
Scala/Java ConcurrentHashMap
scala> val mymap = new ConcurrentHashMap[String, Int]
mymap: java.util.concurrent.ConcurrentHashMap[String,Int] = {}
scala> mymap.put("one", 1)
res8: Int = 0
scala> mymap.put("zero", 0)
res9: Int = 0
scala> mymap.get("one")
res10: Int = 1
scala> mymap.get("zero")
res11: Int = 0
scala> mymap.get("two")
res12: Int = 0
scala> val mymap = new ConcurrentHashMap[String, Option[Int]]
mymap: java.util.concurrent.ConcurrentHashMap[String,Option[Int]] = {}
scala> mymap.put("one", Some(1))
res17: Option[Int] = null
scala> mymap.get("two")
res18: Option[Int] = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment