Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 25, 2011 clear() | ||||
---|---|---|---|---|
| ||||
To empty many arrays of various types, rather than: clear(arr1); clear(arr2); ... clear(arrN); is there something like: clear(ALL); Also, after "clear(arr)", will "arr ~= value" assign starting from element 0? |
March 25, 2011 Re: clear() | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dr.Smith | On Fri, 25 Mar 2011 15:10:44 -0400, Dr.Smith <iam@notfar.com> wrote: > To empty many arrays of various types, rather than: > > clear(arr1); > clear(arr2); > ... > clear(arrN); > > is there something like: > > clear(ALL); Not sure what this would do. Clear all arrays? That isn't possible. > Also, after "clear(arr)", will "arr ~= value" assign starting from element 0? Yes. -Steve |
March 28, 2011 Re: clear() | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dr.Smith | On 03/25/2011 01:10 PM, Dr.Smith wrote: > To empty many arrays of various types, rather than: > > clear(arr1); > clear(arr2); > ... > clear(arrN); > > is there something like: > > clear(ALL); No, but perhaps you can do a: foreach(a; ALL) a.clear() But that would require you having an iterable sequence that contains all of your arrays, which may or may not be worth your time to explore. > > Also, after "clear(arr)", will "arr ~= value" assign starting from element 0? Yes |
March 29, 2011 Re: clear() | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai Meyer | On Mon, 28 Mar 2011 16:57:17 +0200, Kai Meyer <kai@unixlords.com> wrote: > On 03/25/2011 01:10 PM, Dr.Smith wrote: >> To empty many arrays of various types, rather than: >> >> clear(arr1); >> clear(arr2); >> ... >> clear(arrN); >> >> is there something like: >> >> clear(ALL); > > No, but perhaps you can do a: > foreach(a; ALL) > a.clear() That should probably be foreach ( a; ALL ) clear( a ); -- Simen |
Copyright © 1999-2021 by the D Language Foundation