Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How to initialize an emty vector of Float64

$
0
0

@QUANG_VU_NGUY_N_PH_M wrote:

struct A{T}
    time::Vector{Float64}
    data::Vector{T}
end

I would like to initialize an empty object of class A

I tried with outer constructor as below

A() = A([],[])

But it failed:

 julia> a = A()
ERROR: MethodError: no method matching A(::Array{Any,1}, ::Array{Any,1})
Closest candidates are:
  A(::Array{Float64,1}, ::Array{T,1}) where T at none:3
Stacktrace:
 [1] A() at .\none:1
 [2] top-level scope at none:0

Thus, I tried to find out how to initialized

A() = A(Array{Float64}[],[])

This is also failed

julia> a = A()
ERROR: MethodError: no method matching A(::Array{Array{Float64,N} where N,1}, ::Array{Any,1})
Closest candidates are:
  A(::Array{Float64,1}, ::Array{T,1}) where T at none:3
Stacktrace:
 [1] A() at .\none:1
 [2] top-level scope at none:0

How should we initialized an emtpy vector of Float64 type?

Posts: 5

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles