fork download
  1. -- your code goes here
  2.  
  3. o = {}
  4. setmetatable(o, { __index = function(target, key)
  5. if key ~= "foo" then error('ERR') end
  6. if flag then return 1 end
  7. return 2
  8. end})
  9.  
  10. flag = false
  11. print(o.foo)
  12. flag = true
  13. print(o.foo)
Success #stdin #stdout 0s 2832KB
stdin
Standard input is empty
stdout
2
1