Skip to content

Instantly share code, notes, and snippets.

@deanwampler
Last active March 6, 2021 21:46
Show Gist options
  • Save deanwampler/62fa2e8d3d25c2dde249c80f9b1d56fa to your computer and use it in GitHub Desktop.
Save deanwampler/62fa2e8d3d25c2dde249c80f9b1d56fa to your computer and use it in GitHub Desktop.
// Adapted from https://github.com/deanwampler/programming-scala-book-code-examples/blob/master/src/script/scala/progscala3/typesystem/poly/PolymorphicFunctions.scala
scala> def toMap[K,V](key: K)(value: V): Map[K,V] = Map(key -> value)
def toMap[K, V](key: K)(value: V): Map[K, V]
scala> toMap("one")(1.1)
val res0: Map[String, Double] = Map(one -> 1.1)
scala> toMap(2L)("two")
val res1: Map[Long, String] = Map(2 -> two)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment