Advertisement
Guest User

var references in groovy closures

a guest
Feb 28th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //slaves
  2. def machines = ['a', 'b', 'c']
  3.  
  4. //container
  5. def ds = [:]
  6.  
  7. for (machine in machines) {
  8. //prints "Adding entry a\n...Adding entry b\n..." as expected
  9. print("Adding entry for: " + machine);
  10.  
  11. ds[machine] = {download_builds( machine )}; //entry is added, apparently.
  12. }
  13.  
  14. //execute all closures in hash ds concurrently
  15. parallel ds;
  16.  
  17. //They all execute download_builds('c'); ... ? Because the last assignment made to 'machine' was 'c'?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement