Groovy Control Flow

Groovy control flow and looping tutorials. Covers for loops, each(), times(), switch statements, find(), findAll(), and pattern matching.

10 Practical Groovy findAll() Examples to Filter Collections

Groovy findAll() makes filtering collections effortless. Filter lists, maps, and strings with 10 tested examples. Complete filtering guide for Groovy 5.x. “Filtering is the art of keeping only what matters. In Groovy, findAll() makes that art effortless.” Venkat Subramaniam, Programming Groovy 2 Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 16 minutes Filtering is one of the most common collection operations in any language. You have a list of ... Read More

10 Groovy Switch Statement Examples with Pattern Matching

The enhanced Groovy switch statement goes far beyond Java’s version. See 10 examples matching strings, ranges, regex, classes, and closures. Tested on Groovy 5.x. “Java’s switch is a gate with a few locks. Groovy’s switch is a gate that accepts fingerprints, retina scans, and a secret handshake.” Martin Fowler, Refactoring Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 20 minutes The groovy switch statement goes far beyond what Java ... Read More

10 Quick Groovy times() Loop Examples to Repeat Actions Easily

Learn Groovy times loop with times() with 10 practical examples. Repeat actions N times with clean syntax. Complete guide tested on Groovy 5.x. “Simplicity is the ultimate sophistication. Why write a for loop when you can just say how many times?” Alan Kay, Smalltalk Pioneer Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Beginner | Reading Time: 14 minutes Ever written a for loop just to repeat something a fixed number of times and thought, ... Read More