Groovy

Groovy programming language tutorials, examples, and best practices.

Groovy Closure Parameters – it, delegate, owner Explained with 10 Examples

Groovy closure delegate and parameters: it, delegate, owner, and thisObject explained with 10+ examples. Covers delegation strategies and DSL patterns. Tested on Groovy 5.0.6. “A closure without understanding its delegate is like a letter without knowing the recipient — it might arrive somewhere, but probably not where you intended.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 16 minutes Closures in Groovy go far deeper than anonymous blocks of code you ... Read More

Groovy Curry and Partial Application – Complete Guide with 10 Examples

Every Jenkins pipeline has a logging closure that takes a level, a tag, and a message, and every single call passes the same first two arguments. Groovy curry exists for exactly that itch: pre-fill some parameters of a closure and get back a leaner one. This guide covers curry(), rcurry(), and ncurry() with 10 tested examples on Groovy 5.0.6. “Currying is the art of asking for less — turning a function that needs three ingredients into one that already has ... Read More

Groovy Higher-Order Functions – collect, inject, groupBy with 10 Examples

Half the Groovy that shows up in code reviews is a loop that builds a list by hand. Groovy collect replaces that whole pattern with one line, inject folds a collection down to a single value, and groupBy partitions data for reports. This guide works through those higher-order functions, plus collectEntries and collectMany, with tested output on Groovy 5.0.6. “Give me a collection and a closure, and I will give you back a transformed world.” Last Updated: July 2026 | ... Read More