Home > Groovy > 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:

class CurrencyAmount {
    Number amount
    String currency
    String toString() { "$amount $currency" }
}

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

10.euros
//Output: 10 EUR

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.

  • Share/Bookmark

Related posts:

  1. Reason of silence
Categories: Groovy Tags:
  1. July 8th, 2009 at 12:54 | #1

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

  1. No trackbacks yet.