@Tammas Array{T}(0) works in 0.4-dev, but I think that's why there is also
a Vector{T} typealias for Array{T,1}, so it could be Vector{T}(0) which is
slightly better IMHO.
julia> Vector{Int}(0)
0-element Array{Int64,1}
julia> Array{Int,1}(0)
0-element Array{Int64,1}
julia> Array{Int}(0)
0-element Array{Int64,1}
El jueves, 12 de marzo de 2015, 8:10:14 (UTC-6), Tamas Papp escribió:
>
>
> On Thu, Mar 12 2015, Ivar Nesje wrote:
>
> >>
> >> So, what you would want to do is `Array{String,1}()`.
> >> That ought to construct a array of strings with dimension 1 but
> doesn't.
> >
> >
> > But in 0.4 you can use Array{String,1}(0) to create a 1d array with 0
> > elements. Note that you have to provide the size of the array, and 0 is
> not
> > default (, but maybe it should be?)
>
> Array{T}(dims...)
>
> is equivalent to
>
> Array{T,length(dims)}(dims...)
>
> while the latter has a redundant parameter. So instead of providing a
> default for dims..., wouldn't
>
> Array{T}(0)
>
> be an idiomatic solution for creating an empty vector of eltype T? Has
> one less character than
>
> Array{T,1}(0)
>
> :D
>
> Best,
>
> Tamas
>