Friday 1 October 2021

Exercise Using AST Transformations in Groovy Scripting groovy training in telugu 12

 Watch This Video

[Exercise] Using AST Transformations
In this exercise we are going to accomplish 2 goals.

Get a little more familiar with the Groovy API Docs
Learn how to use AST Transformations
We have already shown in previous lectures the ToString and Immutable AST Transformations.
I want you to find 2 more and create either an example or examples of how to use them. Again there is no correct answer here. Browse the Groovy API Docs below and find 2 that you would like to give a test a drive.

import groovy.transform.Cannonical
class Customer{
String fname,lastname
int age
Date since
Collections favItems=["Food']
def object

def d=new Date()
def anyObject =new Object()
def c1=new Customer(fname:"ram",lname:"krishna",age:25,since:d,favItems:["Books","Games"],object:anyObject)
fef c2=new Customer("ram","krishna",25,d,["Books","Games"],anyObject)
assert c1==c2

import groovy.transform.*


class Person{
String first
String last
def p1=new Person(first:"joe",last:"vega")
def p2=new Person(first:"Dan",last:"vega")
def people=[p1,p2]
println people

No comments:

Post a Comment

Note: only a member of this blog may post a comment.