TOP 10 Groovy Closure usage examples - users choice
The story
A couple of months ago, I asked Groovy users on Twitter about their favorite example of using Groovy closures. My goal was to collect some data, process it, and write a blog post. Unfortunatelly, it never happened.
Groovy Closures Twitter Survey
18 people answered to my tweet and shared many interesting examples. I couldn't waste so many useful data, and that is why a few days ago I decided to do something with it.
The solution
Instead of writing a blog post, I thought I will record a short video where I can show all examples in the IDE and add some commentary to it.
Groovy Closures Explained video
What's inside?
- A quick introduction to Groovy closures.
- Collection bulk operations with closures.
- Currying and closure composition.
- Using
Map.withDefault
withClosure.IDENTITY
and method pointer - Regex matcher.replaceAll with a closure
- Closure to SAM coercion example
Collection.inject
example- Closure delegation
- Groovy DSL Builders
File.eachLine
exampleSystem.in.eachLine
example- BONUS information about Groovy 🙂