julia - Julia: "Method error" while calling a parametric function
问题描述
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.
解决方案
从@tamasgal 评论中,正确答案是:“错误与上面的代码无关。它说它不能用两个浮点数组执行+,这很好,但是在你的例子中没有调用+。”
推荐阅读
- powerbi - powerBI 地图不显示城市
- python - 对复杂的python字典进行排序?
- python - 在未堆叠的条形图上添加值 - python
- python - python - 带有通配符的 MySQLdb Like 运算符
- android-studio - 为什么每次我在 android studio 的实际设备上运行我的应用程序时,gradle build 都会失败?
- firebase - 一个用于 GCM 和 FCM 的 Azure 通知中心
- php - Laravel:控制器功能中的未定义变量
- javascript - svg.js 用动画导出 svg
- java - 如何将 AWS Elastic Beanstalk spring boot java 应用程序连接到 VisualVM [不适用于 tomcat]
- node.js - 使用 @octokit 对 Github 应用程序进行身份验证