Skip to content

Instantly share code, notes, and snippets.

@gakuzzzz
Created April 20, 2012 04:59
Show Gist options
  • Save gakuzzzz/2426126 to your computer and use it in GitHub Desktop.
Save gakuzzzz/2426126 to your computer and use it in GitHub Desktop.
scala の ConcurrentMap と withDefault
scala> import scala.collection._
import scala.collection._
scala> import scala.collection.JavaConverters._
import scala.collection.JavaConverters._
scala> val m: mutable.ConcurrentMap[Int, Int] = new java.util.concurrent.ConcurrentHashMap().asScala
m: scala.collection.mutable.ConcurrentMap[Int,Int] = Map()
scala> val m2 = m.withDefault(2*)
m2: scala.collection.mutable.Map[Int,Int] = Map()
scala> m2.get(4)
res0: Option[Int] = None
@gakuzzzz
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment