Skip to content

Instantly share code, notes, and snippets.

@j-thepac
Last active December 18, 2021 15:20
Show Gist options
  • Select an option

  • Save j-thepac/781d4c99d5f7dc7bc434eeda78e010b7 to your computer and use it in GitHub Desktop.

Select an option

Save j-thepac/781d4c99d5f7dc7bc434eeda78e010b7 to your computer and use it in GitHub Desktop.
SimpleFunctor
case class Bag[Int](a: Int) {
def map[Double](f: Int => Double): Bag[Double] = Bag(f(a))
}
val f = i:Int => i/1.0
Bag(10).map( i=> f(i))//result =Bag(10.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment