First groovy experiences

First groovy experiences

Currently I’m staying at copenhagen at the GR8Conf (Grooy, Grails and Griffon confernence). In the talk of the day by Guillaume Laforge about DSLs he showed the following code:

[sourcecode language=”groovy”]
class CurrencyAmount {
Number amount
String currency
String toString() { "$amount $currency" }
}

Number.metaClass.getEuros {->
new CurrencyAmount(amount:delegate, currency:"EUR")}

10.euros
//Output: 10 EUR
[/sourcecode]

It is really interesting to see where in the java world the language evolvement happend. It’s a bit similiar (I’m careful here, because I do not know groovy very well) to the extension methods in .Net.

For me groovy and grails are very interesting technologies, so I will stay up to date.

One thought on “First groovy experiences

  1. More post please! you are leaving a poor old man hungry for more :[

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.