Groovy is an expressive language, that is what we are going to talk about making the usage of “with” method for specifying closure delegate and making our code more succinct (brief and clearly expressed). In my recent project, I was writing a code to resolve tenant and setting some properties to object tenant. resolver.tenant.subdomain = “india” resolver.tenant.username […]
Recently, I saw some code of grails Hibernate Plugin and noticed an interesting usage of ‘as’ operator. The ‘as’ operator of groovy is typically used to change the types of objects. For example: [groovy] int a = "20" as int assert a==20 [/groovy] The ‘as’ operator can be used to provide implementation to interface as […]
In one of my recent grails project, I had a requirement to get unique objects from a list based on more than one field. Now, this can be done by passing the list to closure unique. I had a list of dates of a couple of years, and what I needed was a unique combination […]