Search code examples
arraysiteratorjuliaallocation

How to collect an iterator into an exiting container?


If I have a iterators, say a=1:10 and an array that I've already allocated (x = zeros(10)), how can I collect my array into the container without allocating a new array?

E.g. does something like collect!(x, a) exist?


Solution

  • copyto!(x, 1:10)
    

    Filling the void here to 30 characters