Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Created February 27, 2015 01:05
Show Gist options
  • Save wrobstory/47d0c8a6aa76d127c7d3 to your computer and use it in GitHub Desktop.
Save wrobstory/47d0c8a6aa76d127c7d3 to your computer and use it in GitHub Desktop.
World's Most Advanced Type System
scala> val listOfTuples = List(("one", Map("foo" -> 1, "bar" -> 2)),
| ("two", Map("baz" -> 3, "qux" -> 4)),
| ("three", Map()))
listOfTuples: List[(String, scala.collection.immutable.Map[_ <: String, Int])] = List((one,Map(foo -> 1, bar -> 2)), (two,Map(baz -> 3, qux -> 4)), (three,Map()))
scala> val thirdTuple = listOfTuples(2)
thirdTuple: (String, scala.collection.immutable.Map[_ <: String, Int]) = (three,Map())
scala> val thirdTupleMap = thirdTuple._2
thirdTupleMap: scala.collection.immutable.Map[_ <: String, Int] = Map()
scala> thirdTupleMap.get("foo")
<console>:11: error: type mismatch;
found : String("foo")
required: _1
thirdTupleMap.get("foo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment