[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Accessing String contents
- From: Michal Kottman <k0mpjut0r@...>
- Date: Thu, 21 Jun 2012 12:08:32 +0200
On 21 June 2012 11:48, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> There's some good (though advanced) stuff on the Lua Wiki:
>
> http://lua-users.org/wiki/StringIndexing
I just read the Wiki and I noticed that there is almost byte-to-byte
exact code to what I have written myself independently from my own
head (honestly!):
getmetatable('').__index = function(str,i)
if type(i) == 'number' then
return string.sub(str,i,i)
else
return string[i]
end
end
Now imagine if the code on the Wiki was patented...