resize!
resize!(collection, n) -> collection
Resize collection
to contain n
elements.
If n
is smaller than the current collection length, the first n
elements will be retained. If n
is larger, the new elements are not
guaranteed to be initialized.
julia> resize!([6, 5, 4, 3, 2, 1], 3)
3-element Array{Int64,1}:
6
5
4
julia> resize!([6, 5, 4, 3, 2, 1], 8)
8-element Array{Int64,1}:
6
5
4
3
2
1
0
0
Examples
julia> foo = [6, 5, 4, 3, 2, 1];
julia> resize!(foo, 3); foo
3-element Array{Int64,1}:
6
5
4
julia> resize!(foo, 5); foo
5-element Array{Int64,1}:
6
5
4
0
0
See Also
append!, delete!, deleteat!, empty!, endof, filter, filter!, gc, get!, getkey, haskey, insert!, isempty, keys, map, map!, merge, merge!, pop!, prepend!, push!, reduce, resize!, shift!, splice!, unshift!, values,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.