So many sample show that need to declare each variable in next line such as below:
class RelationTest {
String name
String password
String email
String age
String height
String weight
static constraints = {
name maxSize:10, blank: false
password minSize:6, blank: false
email email:true,blank: false
age min: 18
height()
weight()
}
}
But why not instead like this below:
class RelationTest {
String name,password,email,age,height,weight
static constraints = {
name maxSize:10, blank: false
password minSize:6, blank: false
email email:true,blank: false
age min: 18
height()
weight()
}
}
or it must be declare each variable on each line.?
This is done for readability, and how historically properties of a Bean/Class were defined in Java. It's much easier to spot an individual property in the first example, rather than having to read the entire list on on one line.
Technically there is no difference in Groovy. It's just readability.