(no title)
RagingCactus | 7 years ago
> Notice how state was introduced? It made the code easier to read.
Correct me if I'm wrong, but the only state in that snippet lives in Stream.iterate(), the Fibonacci object is still immutable and next() on it is a pure function. To me this still looks very much like a functional programming approach.
Which just shows that moving business logic into properly named abstractions is good, no matter the programming paradigm.
The real stateful example is the IncrementSupplier and the impure get() method. I personally don't really like it ( Stream.iterate(0, i -> i + 1) is pretty readable to me), but that's probably just personal taste.
No comments yet.