functional-programming

Functional programming techniques: closures, higher-order functions, composition, currying, and method references, with tested examples.

Groovy Streams vs Closures – When to Use What (10+ Examples)

Your Java teammates write stream().filter().map() while your Groovy code says findAll and collect, and sooner or later a code review asks which style belongs in the codebase. Groovy streams work exactly as they do in Java, and the native closure methods often read better. This guide compares both with 10 tested examples on Groovy 5.0.6 so you know when each wins. “Groovy gives you two paths to functional programming – Java Streams and native closures. Knowing when to walk which ... Read More

Groovy Closure Composition & Chaining – Build Pipelines with 12 Examples

Groovy closure composition with leftShift, rightShift, and chaining. 12 examples covering compose, andThen, pipelines, and functional patterns. Groovy 5.0.6. “Composition is the essence of programming. We compose functions to build bigger functions, just as we compose words to build sentences.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate to Advanced | Reading Time: 19 minutes If you’ve been following our closures series – starting with the Groovy Closures Complete Guide – you’ve seen closures ... Read More

Groovy Method References & Method Pointers Explained with 12 Examples

Groovy method references and method pointers with the .& operator. 12 examples covering instance, static, and constructor references. Tested on Groovy 5.0.6. “A method pointer is a closure that was always hiding inside your method – Groovy just gives you the key to unlock it.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 18 minutes If you’ve been working through the closures section of this series – starting with our Groovy ... Read More