Reputation: 35
I've hit my next roadblock in some code I'm trying to debug and work through.
ERROR: LoadError: MethodError: no method matching Array(::Type{Int64}, ::Int64)
Closest candidates are:
Array(::LinearAlgebra.UniformScaling, ::Integer, ::Integer) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\LinearAlgebra\src\uniformscaling.jl:345
I looked through material provided and it looks like array definitions may have changed to using arr
or Array{Int64,0}
... but those didn't seem to work for me either. Any advice? Thank you in advance!
# Puts the output of one lineup into a format that will be used later
if status==:Optimal
data_lineup_copy = Array(Int64, 0)
for i=1:num_data
if getValue(data_lineup[i]) >= 0.9 && getValue(data_lineup[i]) <= 1.1
data_lineup_copy = vcat(data_lineup_copy, fill(1,1))
else
data_lineup_copy = vcat(data_lineup_copy, fill(0,1))
end
end
for i=1:num_shot
if getValue(shot_lineup[i]) >= 0.9 && getValue(shot_lineup[i]) <= 1.1
data_lineup_copy = vcat(data_lineup_copy, fill(1,1))
else
data_lineup_copy = vcat(data_lineup_copy, fill(0,1))
end
end
return(data_lineup_copy)
end
end
data1 = Array(Int64, 0)
data2 = Array(Int64, 0)
data3 = Array(Int64, 0)
Upvotes: 0
Views: 463
Reputation: 5583
Array(Int64, 0)
would create an empty Int64
1D array (i.e. Vector
) on older versions (probably pre-0.6 era).
Now, to create an empty Int64
1D array, you can use any of
data1 = Array{Int64, 1}(undef, 0) # where `1`, the second type parameter is for the dimension
data1 = Array{Int64}(undef, 0)
data1 = Vector{Int64}(undef, 0)
data1 = Vector{Int64}()
data1 = Int64[]
You can always consult to the official documentation for different ways of array construction in Julia.
Upvotes: 2