[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: local _META = {string = {__index = function(s, k) if type(k) == "number" then return string.sub(s, k, k) end return string[k] end}}
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 8 Dec 2014 18:15:14 +0200
2014-12-08 17:52 GMT+02:00 Thiago L. <fakedme@gmail.com>:
> Hi!
>
> Can we get a local _META, like _ENV but for metatables?
>
> s = "test"
> print(s:sub(1,2))
> do
> local _META = {string = {__index = {sub = function(s, i, j) return "nope"
> end}}}
> print(s:sub(1,2))
> end
> print(s:sub(1,2))
>
> would output:
>
> te
> nope
> te
Do you expect the relationship
`_ENV.string == getmetatable"".__index`
to survive?