What does `() => Unit` mean?
2 answers
First, you have a list of features. Each function takes no parameters (that's what the open-close parentheses mean ()
) and returns Unit
, which is a value with no result, similar to void.
In a pure functional world, a type function is ()=>Unit
useless because it accepts nothing and returns nothing. However, Scala is not a purely functional language; it has side effects. To be useful, the functions on the list will undoubtedly have side effects. Since they are callback functions, they also have an idea of when they fire.
+4
source to share