[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Next Lua (5.2) feature request : slicing
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Tue, 21 Nov 2006 18:43:25 -0500
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.