fork download
  1. def rand = new Random()
  2. def departments = ['HR', 'Fecilities', 'R&D', 'Services', 'Security', 'IT', 'Sales', 'Marketing', 'Finance']
  3. def getRandomDepartment = { departments[rand.nextInt(departments.size -2) + 1] }
  4. //println getRandomDepartment()
  5.  
  6. //Sample data source generation using department
  7. println "Employee ID, Department"
  8. (1..10).each { println "$it, ${getRandomDepartment()}" }
Success #stdin #stdout 2.73s 143524KB
stdin
Standard input is empty
stdout
Employee ID, Department
1, Fecilities
2, IT
3, R&D
4, Services
5, Fecilities
6, Sales
7, R&D
8, Security
9, Marketing
10, IT