Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Created January 22, 2012 10:51
Show Gist options
  • Save seanparsons/1656555 to your computer and use it in GitHub Desktop.
Save seanparsons/1656555 to your computer and use it in GitHub Desktop.
Map.get returns None.
val javaMap = new java.util.HashMap[String, Int]()
javaMap.put("Cake", 4)
import scala.collection.JavaConversions._
import scala.collection.mutable.Map
val map: Map[String, Int] = mapAsScalaMap(javaMap)
map.get("Dave")
// Returns: res2: Option[Int] = None
// This does not compile:
// scala> map.get(4)
// <console>:14: error: type mismatch;
// found : map.type (with underlying type scala.collection.mutable.Map[String,Int])
// required: ?{val get(x$1: ?>: Int(4) <: Any): ?}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment