lua-users home
lua-l archive

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


On 02.08.2010 09:57, Matthew Wild wrote:
> 2010/8/2 Michal Kolodziejczyk <miko@wp.pl>:
>> On 31.07.2010 23:08, Luiz Henrique de Figueiredo wrote:
>>
>>> See also http://www.lua.org/work/doc/
>>>
>>> The manual has been updated but is still incomplete.
>>
>> 3.4.6 - The Length Operator
>>
>> "A program can modify the behavior of the length operator for any value
>> but strings through metamethods" - shouldn't that read "but string and
>> numbers"?
> 
> $ lua5.2
> Lua 5.2.0 (work4)  Copyright (C) 1994-2010 Lua.org, PUC-Rio
>> require"debug".setmetatable(1, { __len = function (n) return math.random(n) end })
> true
>> return #5
> 2
>> return #5
> 4
>> return #5
> 4
>> return #5
> 5
>> return #5
> 1
>>
> 
> :)

Ops ;) I tried setmetatable instead of debug.setmetatable. So the docs
are OK. Thanks!
miko