lua-users home
lua-l archive

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


2015-06-05 17:29 GMT+02:00 Dibyendu Majumdar <mobile@majumdar.org.uk>:
> On 5 June 2015 at 16:04, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>> 2015-06-05 16:35 GMT+02:00 Dibyendu Majumdar <mobile@majumdar.org.uk>:
>>
>>> Didn't realize that Lua types have a metatable associated with them.
>>> What are they used for?
>>
>> Fooling around, mostly. There have been interesting posts on this
>> list on what you can do with metatables for nil and function, for
>> example. In the case of string, of course, the metatable is already
>> exploited by the string library.
>>
>
> To support indexing of a string's characters via [] it seems.
>
> Interesting.

No, it's to give object-oriented access to the routines in the
string library. But people have exploited it to do what you say:

http://lua-users.org/wiki/StringIndexing