Last active
March 6, 2021 21:48
-
-
Save deanwampler/8ecf73e853ce6867131205e2cd81684b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from: | |
// https://github.com/deanwampler/programming-scala-book-code-examples/blob/master/src/main/scala/progscala3/typesystem/typelambdas/Functor.scala | |
// https://github.com/deanwampler/programming-scala-book-code-examples/blob/master/src/script/scala/progscala3/typesystem/typelambdas/Functor.scala | |
// import the.package.given // If the givens were defined in package or object somewhere. | |
scala> Seq(1,2,3).map2(_ * 2.2) | |
| Nil.map2(_.toString) | |
val res0: Seq[Double] = List(2.2, 4.4, 6.6000000000000005) | |
val res1: Seq[String] = List() | |
scala> Some(1).map2(_ * 2.2) | |
| None.map2(_.toString) | |
val res2: Option[Double] = Some(2.2) | |
val res3: Option[String] = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment