lua-users home
lua-l archive

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


Mildred wrote:
> The problem with that solution is that slicing assigment is 
> not possible. Something like a[1:3]=b[2:4], but I don't think 
> it is very used. And it is still better to have basic slicing 
> than nothing.

You can add the same multiple index mechanism to the newindex
metamethod:
a[1:3] = b[2:4]
a[1,3] = b[2,4]
getmetatable(a).__newindex(a, 1, 3, getmetatable(b).__index(b, 2, 4))

However it would be irrelevant for strings since they are immutable.