No matching method in subtraction
I am using julia 0.5 after running this code:
Freqsample = 100;
second = 4;
step = (Freqsample * second )-1
i am getting this error:
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
What's wrong with subtraction? i am pretty new to julia, sorry if its a dumb question
source to share
You have overridden -
for more types than you intended. The second line in the layout you laid out tells you that Julia called a method -
in main.jl
for two integers. And the first line says that inside it, it is trying to do something like x[:, 1:5]
on line 12, where x
is an integer.
This tells me two things:
-
Your definition
-
is probably too believable. You probably didn't want to accept integers. -
Perhaps you are shadowing the inline definition
-
rather than extending it. You needimport Base: -
to add a new method to a function in the standard library.
source to share