Here is an article about it.
If the lambda is simple enough which does not need unit testing, inline code is ok.
If the lambda is complicated which does need unit testing, it should be written into one static method. We use the method reference in the lambda place. We can have unit testing on that static method.
The static method can be public , default, protected or private. The method reference "ContainingClass::staticMethodName" works for all of them, even it is private. :)
No comments:
Post a Comment