home search about rss feed twitter ko-fi

Higher-Order Functions, Part 2 (video) (Scala 3)

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

val xs = List(1, 2, 3)
def isEven(i: Int): Int = i % 2 == 0
val ys = filter(xs, isEven)

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