Le mercredi 04 février 2015 à 02:00 -0800, Kristoffer Carlsson a écrit : > If you want to allocate an Array you can simply write: > > > > julia> Array(Int, 5, 1) > 10x1 Array{Int64,2}: > 2187293504 > 2151034912 > 2195818528 > 2147516504 > > > > Now, Vector is a short form for Array{T, 1}. I would then expect to be > able to allocate a vector using something like this: > > > julia> Vector(Int, 5) > ERROR: MethodError: `convert` has no method matching > convert(::Type{Array{T,1}}, > ::Type{Int64}, ::Int64) > This may have arisen from a call to the constructor Array{T,1}(...), > since type > constructors fall back to convert methods in julia v0.4. > Closest candidates are: > convert{T}(::Type{Nullable{T}}, ::T) > convert{T}(::Type{T}, ::T) > convert{T}(::Type{FloatRange{T}}, ::FloatRange{T<:FloatingPoint}) > ... > > > Could someone help me with the syntax? Do you have to use the Array > form every time you want to initiate a Arrat{T,1} with a certain > length? As you can see from the printed output, Array(Int, 5, 1) creates an Array{Int, 2}, which is different from a Vector. If you want a Vector, call Array(Int, 5). I've often tried typing Vector(Int, 5) too, and wished it existed, but as it would be redundant with Array(), I'm not sure it's a good idea to add it.
Regards