I have read the blog post recommended me here. Now I wonder what some those methods are useful for. Can you show examples of using forall
(as opposed to foreach
) and toList
of Option
?
I have one practical example of toList
method. You can find it in scaldi (my Scala dependency injection framework) in Module.scala at line 72:
In this context getBindings
method can return either Nil
or List
with only one element. I can retrieve it as Option
with discoverBinding
. I find it convenient to be able to convert Option
to List
(that either empty or has one element) with toList
method.