Making a Groovy class a range

In a recent post, I used the Date class in a range. This always jumps out at Java developers, who aren’t used to seeing it. [sourcecode language=”java”] def now = new Date() def then = now + 9 assert 10 == (now..then).size() [/sourcecode] It’s really cool you can do that in Groovy. That example illustrates… Read More

Links from my GroovyMag article

I’m really happy to have an article in the current issue of GroovyMag, but after it appeared I realized something. When I submitted the article I added several links in the text, thinking that they would still be active in the resulting PDF. That, as they say, turned out not to be the case. I… Read More

Groovy Groundhogs

So the groundhog saw his shadow today, implying six more weeks of Winter. ┬áLet’s settle this nonsense once and for all. [sourcecode language=”java”] def cal = Calendar.instance cal.set(2009,Calendar.FEBRUARY,2) def ghday = cal.time cal.set(2009,Calendar.MARCH,21) def spring = cal.time def days = (ghday..spring).size() println “Between Feb 2 and Mar 21, there are $days days” [/sourcecode] The output… Read More