digitalmars.D.learn - clear()
- Dr.Smith (8/8) Mar 25 2011 To empty many arrays of various types, rather than:
- Steven Schveighoffer (4/13) Mar 25 2011 Yes.
- Kai Meyer (7/15) Mar 28 2011 No, but perhaps you can do a:
- Simen kjaeraas (6/20) Mar 28 2011 That should probably be
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?
Mar 25 2011
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
Mar 25 2011
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
Mar 28 2011
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:That should probably be foreach ( a; ALL ) clear( a ); -- SimenTo 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()
Mar 28 2011