Search code examples
juliajulia-jump

Why is the " UndefVarError: undef not defined " error happened?


It is used in the code: tt=Array{Int64}(undef,0) but the following error is shown: UndefVarError: undef not defined would you please say why it happened? and is there any alternative for the code?


Solution

  • If you want an empty vector just write (should work in very old and new Julia):

    tt = Int64[]
    

    or even tt = Int[] if you are on a system with 64 bit ints (which is almost always true)