Creating a copy of elements from a collection to an array in Julia – copyto!() Method
The copyto!() is an inbuilt function in julia which is used to copy all elements from the specified collection src to array dest.
Syntax:
copyto!(dest::AbstractArray, src)Parameters:
- dest::AbstractArray: Specified destination array.
- src: Specified source collection.
Returns: It returns the copied elements from the specified collection src to array dest.
Example 1:
# Julia program to illustrate # the use of copyto !() method # Getting copied elements from the # specified collection src to array desta = [1, 2, 3, 4, 5];b = zeros(8);copyto !(b, a);println(b) |
Output:
Example 2:
# Julia program to illustrate # the use of copyto !() method # Getting copied elements from the # specified collection src to array desta = [1., 2., 3., 4., 5.];b = ones(8);copyto !(b, a);println(b) |
Output:


