use

The use() block for applying Groovy categories temporarily.

Groovy Categories and Mixins – Extend Existing Classes with 10+ Examples

Learn Groovy categories and mixins with 10+ tested examples. Add scoped methods to classes, compose behaviors, and extend JDK classes safely. “Categories let you try on new methods like clothes – wear them when you need them, take them off when you’re done.” Dave Thomas, The Pragmatic Programmer Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Intermediate | Reading Time: 18 minutes Adding methods globally with ExpandoMetaClass is powerful but permanent (until cleanup). What if ... Read More