减法中没有方法匹配 [英] no method matching in subtraction
问题描述
运行此代码后,我正在使用julia 0.5:
I'm using julia 0.5 after run this code :
Freqsample = 100;
second = 4;
step = (Freqsample * second )-1
我收到此错误:
MethodError: no method matching getindex(::Int64, ::Colon, ::UnitRange{Int64})
in -(::Int64, ::Int64) at main.jl:12
in include_string(::String, ::String) at loading.jl:441
in eval(::Module, ::Any) at boot.jl:234
in (::Atom.##65#68)() at eval.jl:40
in withpath(::Atom.##65#68, ::Void) at utils.jl:30
in withpath(::Function, ::Void) at eval.jl:46
in macro expansion at eval.jl:109 [inlined]
in (::Atom.##64#67{Dict{String,Any}})() at task.jl:60
减法有什么问题?我对朱莉娅(Julia)很陌生,请问这是一个愚蠢的问题
Whats wrong with subtracting ? i'm pretty new to julia forgive if its a dumb question
推荐答案
您已经重新定义了-
,以获取比预期更多的类型.您发布的回溯中的第二行告诉您Julia在main.jl
中为两个整数调用了-
方法.第一行说在那儿,它试图在第12行做类似x[:, 1:5]
的事情,其中x
是一个整数.
You've redefined -
for more types than you probably intended. The second line in the backtrace you posted is telling you that Julia called a -
method in main.jl
for two integers. And line one is saying that within there it's trying to do something like x[:, 1:5]
at line 12, where x
is an integer.
这告诉我两件事;
-
您对
-
的定义键入的内容可能过于宽松.您可能不打算接受整数.
Your definition of
-
is probably typed too permissively. You probably didn't intend to accept integers.
您可能正在 shadowing 内置的-
定义,而不是对其进行扩展.您需要import Base: -
才能向标准库中的函数添加新方法.
You are probably shadowing the built in -
definition instead of extending it. You need to import Base: -
in order to add a new method to a function in the standard library.
这篇关于减法中没有方法匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!