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. ...
As we all know that groovy is a dynamic programming language, so we can add any method to any class at runtime. First, let’s see a small and simple example of metaProgamming given below, in which we are adding a method (isEvent) into an Integer class. [groovy] Integer.metaClass.isEven = { -> // only (->) sign indicates that...
Suppose a scenario, where User and Account classes are linked as below: [groovy] class Account { String email String password // ... other fields } class User { Account account String name String address // ... other fields } [/groovy] At the time of creating a new User, and accessing the user...