fill!

fill!(A, x)

Fill array A with the value x. If x is an object reference, all elements will refer to the same object. fill!(A, Foo()) will return A filled with the result of evaluating Foo() once.

Examples

julia> foo = Array(Int8,1,2);
julia> fill!(foo, 42)
1x2 Array{Int8,2}:
 42     42

Referencing another collection

 julia> foo = [1,2];
 julia> bar = Array(Any,1);
 julia> fill!(bar,foo)
 1-element Array{Any,1}:
  [1,2]
 julia> foo[1] = 42;
 julia> bar
 1-element Array{Any,1}:
 [42,2]

Using functions

julia> function Foo()
                    4^3
            end;
julia> bar = Array(Int8,2);
julia> fill!(bar, Foo())
2-element Array{Int64,1}:
 64
 64

See Also

Array, broadcast, cat, combinations, conj!, digits!, fieldnames, fill, fill!, last, length, maximum, minimum, ones, parent, parentindexes, partitions, permutations, pointer, pointer_to_array, promote_shape, rand!, reshape, scale, similar, sum, sum_kbn, takebuf_array, transpose!, vec, zeros,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: