Groovy Puzzlers
summary
A rapid-fire set of actual Groovy gotchas: operator precedence makes a call on -3 invoke a method that returns void then NPEs, postfix ++/-- on boxed Integers fails at runtime, max(...) can return the first element when a comparator returns null, and map indexing often uses GString vs String keys so lookups silently miss. Demos run in the Groovy console and are verified on Groovy 2.3.7, with fixes and hints shown using IntelliJ inspections and simple parenthesis or explicit casts.
AI-written summary · about
chapters (22)
- 0:00Introduction to Groovy Puzzlers
- 1:09Rules and setup for the puzzles
- 2:21First puzzle: Minus operator behavior
- 4:51Fixing the first puzzle
- 8:42Second puzzle: Prime number check
- 12:52Fixing the prime number check
- 13:12Third puzzle: Class iteration
- 16:26Fourth puzzle: Custom max method
- 20:10Fifth puzzle: Closure and exception
- 22:45Anonymous blocks in Groovy
- 24:12Sixth puzzle: Countdown logic
- 27:04Fixing the countdown puzzle
- 30:24Seventh puzzle: Default return values
- 34:19Eighth puzzle: Treasure map
- 36:27Fixing the treasure map puzzle
- 39:51Ninth puzzle: Range iteration
- 45:06Tenth puzzle: List with mixed types
- 48:58Fixing the mixed types puzzle
- 51:28Eleventh puzzle: Number properties
- 54:02Fixing the number properties puzzle
- 55:13Lessons and best practices
- 57:01Q&A and closing remarks
