lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> mt.__index = function(o, k)
>   local s = strings[o]
>   if k == "string" then
>     return s
>   else
>     return s.k
>   end
> end

Oops! This is better:

local strindex = getmetatable"".__index
mt.__index = function(o, k)
  local s = strings[o]
  return k == "string" and s or strindex[k]
end

Sorry for the noise.

Cheers,
Luis.

-- 
A mathematician is a device for turning coffee into theorems.
        -- P. Erdos 

-- 
Luis Carvalho
Applied Math PhD Student
Brown University