|Pattern 2||Replacing State-Carrying Functional Interface|
To encapsulate a bit of state along with program logic so it can be passed around, stored in data structures, and generally treated like any other first-class construct
In Pattern 1, Replacing Functional Interface, we saw how to replace Functional Interface with higher-order functions, but the instances we looked at didn’t carry around any program state. In this pattern, we’ll take a look at how we can replace Functional Interface implementations that need state using a powerful construct called a closure.
Also Known As
Function Object Functoid Functor
Functions in the functional world are part of a powerful construct called a closure. A closure wraps ...