times

Using times() to repeat an action N times in Groovy.

Groovy Number Math – Cookbook Guide with 10+ Examples

Groovy number math handling well beyond what Java offers. See 13 tested examples covering BigDecimal defaults, times/upto/downto loops, power operator, integer division, type coercion, abs/round/ceil/floor, currency formatting, random numbers, and numeric ranges. “In most languages, 0.1 + 0.2 equals 0.30000000000000004. In Groovy, it equals 0.3 – because Groovy chose BigDecimal as the default and saved us all from floating-point therapy.” Donald Knuth, The Art of Computer Programming Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: ... 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