fork download
  1. function closure()
  2. {
  3. var i = 0;
  4. return {
  5. update: function(new_i) { i = new_i; },
  6. get_value: function() { return i; }
  7. }
  8. }
  9.  
  10. var c = closure();
  11. print(c.get_value());
  12. c.update(10);
  13. print(c.get_value());
Success #stdin #stdout 0.02s 4984KB
stdin
Standard input is empty
stdout
0
10