home search about rss feed twitter ko-fi

Higher-Order Functions, Part 3 (Scala 3 Video)

In this free Scala 3 video tutorial, I show how to write your own map function in Scala. That is, if you assume that the Scala collections classes didn’t have a built-in map function, this shows how to write your own mapping function, which you can use like this:

val xs = List(1, 2, 3)
def double(i: Int): Int = i * 2
val ys = map(xs, double)

By going through this process you see a real-world use of how to use higher-order functions (HOFs) in Scala.

Update: All of my new videos are now on
LearnScala.dev