0
votes

In a file named "func.jl", I defined the following function:

function testXYZ(xi::Array{T, 1}, yi::Array{T, 1}) where {T<:Float64}
    println("Success")
end

In "main.jl" I did build a minimum example:

include("func.jl");
xs = [0.0, 1.2, 2.0, 5.0, 10.0, 11.0]
ys = [2.0, 2.1, 1.0, 0.0, 0.0, 3.0]
testXYZ(xs, ys)

Checking with the console the types of xs and ys, I obtain as expected:

julia> ys = [2.0, 2.1, 1.0, 0.0, 0.0, 3.0];
julia> typeof(ys)
Array{Float64,1}

While exectuting the minimum example in main I obtain a method error:

ERROR: LoadError: MethodError: no method matching +(::Array{Float64,1}, ::String)

In Julia manual, I found lots of similar errors, but no one solved my problem.

1
Your minimal working example is actually working: tio.run/##VU/LaoUwFFz3fMUhKwMhqH0sbLu4m/…mschauer
The error has nothing to do with the code above. It says that it cannot perform + with two arrays of floats which is fine, however there is no call of + in your example. I think you are mixing up your files maybe?tamasgal
You may want to try restarting your Julia session to make sure the testXYZ function is defined the way you think it is.StefanKarpinski
@tamasgal totally true. ThanksJoe22
@JoeMatt glad to help! Have fun with Julia :)tamasgal

1 Answers

0
votes

From @tamasgal comment, the correct answer is: "The error hasnothing to do with the code above. It says that it cannot perform + with two arrays of floats which is fine, however there is no call of + in your example."