lua-users home
lua-l archive

Re: Accessing String contents

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


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...

AltStyle によって変換されたページ (->オリジナル) /