www.digitalmars.com         C & C++   DMDScript  

D - Dinamic array remove element

reply Ant <Ant_member pathlink.com> writes:
How do we remove an element from a dimamic array?

slicing?

a = a[0..4] ~ a[6..a.length]

this works. is this it?

Ant
Sep 21 2003
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Ant" <Ant_member pathlink.com> wrote in message
news:bkl63u$1d4n$1 digitaldaemon.com...
| How do we remove an element from a dimamic array?
|
| slicing?
|
| a = a[0..4] ~ a[6..a.length]
|
| this works. is this it?
|
| Ant
|
|

No, actually. That should be [0..4]~[5..length] (for the 5th element) or
[0..5]~[6..length] (for the 6th).

—————————————————————————
Carlos Santander
"Ant" <Ant_member pathlink.com> wrote in message
news:bkl63u$1d4n$1 digitaldaemon.com...
| How do we remove an element from a dimamic array?
|
| slicing?
|
| a = a[0..4] ~ a[6..a.length]
|
| this works. is this it?
|
| Ant
|
|

No, actually. That should be [0..4]~[5..length] (for the 5th element) or
[0..5]~[6..length] (for the 6th).

—————————————————————————
Carlos Santander
Sep 21 2003
parent Ant <Ant_member pathlink.com> writes:
In article <bklaf6$1j2s$1 digitaldaemon.com>, Carlos Santander B. says...
"Ant" <Ant_member pathlink.com> wrote in message
| a = a[0..4] ~ a[6..a.length]
No, actually. That should be [0..4]~[5..length] (for the 5th element) or
I're right. Actually my real code is: listRows = listRows[0..row] ~ listRows[row+1..listRows.length]; And I just changed it to: listRows[row..listRows.length-1] = listRows[row+1..listRows.length]; listRows.length = listRows.length-1; //--(listRows.length); -->> not an lValue. shouldn't it be? is it be more efficient? Ant
Sep 21 2003