Appending to Vector

julia

Solution

If you're appending a scalar value, you want `push!`. If you're adding a list of elements, then you want `append!`. There's a good reason for the distinction, as you will probably realize if you consider what should happen if you want to build an array-of-arrays.

Typing `?append!` at the REPL will show you help on the function, including a demo on how to use it. (In julia 0.4, the help has been improved and refers you to the `push!` function as well, but that doesn't seem to have been implemented in the current release.)

Problem

I'm having trouble appending to an empty vector in Julia. ``` v = Int64[] append!(v,1) append(v,1) ``` The append! gives the error ``` ERROR: `Variable` has no method matching Variable(::Int64, ::Int64, ::Int64, ::Int64) ``` And append gives the error ``` ERROR: append not defined ``` This is probably a basic mistake on my part, but I can't figure out why neither command is working.

Original source