Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A quick Lua version:

    do
      local mt = {
        __index = function(t, k)
          t[k] = tree()
          return t[k]
        end
      }
    
      function tree()
        return setmetatable({}, mt)
      end
    end

    t = tree()
    t.foo.bar = 'foobar'


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: