I have the following code:
class User {
String id = ""
}
class Customer {
String id = ""
User[] users
}
Customer[] customers = new Customer[5]
for (i=0;i<numCustomers;i++) {
customers[i] = new Customer()
customers[i].id = "customer:" + (1000+i)
customers[i].users = new User[3]
for (j=0; j<users.size(); j++) {
customers[i].users[j] = new User()
customers[i].users[j].id = customers[i].id
}
}
The initialization of the customers array seems correct. If I only have the "id" field it works fine. However, when I added the "users" field, with the code showed above I get "No such property: users" on the line:
customers[i].users = new User[3]
Why is this? Also, I am new to Groovy, so please point out any other issue with my code above.
for (j=0; j<users.size(); j++)what is theusers? I guess you meantcustomers[i].users...