D - [Beginner] How to add elements to a dynamic array?
- Dave Sieber (8/8) Mar 26 2004 I want to build an array dynamically, similar to std::vector in C++ :
- Ivan Senji (6/14) Mar 26 2004 int[] v;
- Dave Sieber (7/11) Mar 26 2004 Thank you, Ivan. I had seen this notation in the docs, but the doc said ...
I want to build an array dynamically, similar to std::vector in C++ : std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); Can this be done with D arrays? -- dave
Mar 26 2004
int[] v; v ~= 1; v ~= 2; v ~= 3; "Dave Sieber" <dsieber spamnot.sbcglobal.net> wrote in message news:Xns94B860C93E900dsiebersbc 63.105.9.61...I want to build an array dynamically, similar to std::vector in C++ : std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); Can this be done with D arrays? -- dave
Mar 26 2004
"Ivan Senji" <ivan.senji public.srce.hr> wrote:int[] v; v ~= 1; v ~= 2; v ~= 3;Thank you, Ivan. I had seen this notation in the docs, but the doc said it was for array concatenation. In my case, I wanted to add a single element, not another array, so I assumed it was not the correct way. IAC, it compiles with your suggested notation. Now, to test it... :-) -- dave
Mar 26 2004