Remove array element within function
Rekel
paultjeadriaanse at gmail.com
Mon Jul 5 13:34:50 UTC 2021
Ah, ref, thanks, I didn't know if that would work as I was
confused since arrays themselves are kind of already pointers.
On Monday, 5 July 2021 at 13:18:55 UTC, Mike Parker wrote:
> In what situations do you need to manually change the length?
> Where do you worry about copies? It's possible there's
> something you're overlooking.
I believe for setting length it was both when I wanted to
initialize the array to a certain length (instead of having that
inline with the declaration) & when I want to clear the array of
all data. Though I also found threads in which people mentioned
changing the length manually after calling remove.
The copies were mostly at play in scenarios such as this one, but
also when I'm appending lists to lists, in a
`list.addAll(list2);` scenario. Though I guess I'm just not used
to reassigning on the list variable after doing things with it.
Also, is my use of long correct? The documentation wasn't very
clear on the return type of remove, just calling it a 'number'.
Again thanks for your help 😅
More information about the Digitalmars-d-learn
mailing list