# ERROR: MethodError: no method matching +(::String, ::Int64)

**URL:** <https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096>\
**Category:** New to Julia\
**Created:** [November 12, 2023, 12:54am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096 "2023-11-12T00:54:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Mohit](https://discourse.julialang.org/u/Mohit)\
**Post date:** [November 12, 2023, 12:54am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/1 "2023-11-12T00:54:33Z")

</div>

I am trying to learn bioinformatics with julia and was trying to write very basic script.  
But i am getting an error, I am sure that I am missing a very simple concept of usage.  
It will be great help, if someone can explain me.  
Thanks in advance.  
It is pointing error at line:  
ln = ln\_dna- ln\_kmer + 1  
but according to my logic and understanding, i cannot recognize error.

# The programme is to find the the frequency of K-mers in the given sequences

function oric(dna, kmer)  
count = 0  
ln\_dna = length(dna)  
ln\_kmer = length(kmer)  
ln = ln\_dna- ln\_kmer + 1  
for i in 1:ln  
if dna[i:(i+ln\_kmer-1)] == kmer  
count += 1  
end  
end  
println(“Number of k-mers =”, count)  
end

dna = “gcgcg”  
kmer = “gcg”  
oric(dna, kmer)

ERROR: MethodError: no method matching +(::String, ::Int64)

Closest candidates are:  
+(::Any, ::Any, ::Any, ::Any…)  
@ Base operators.jl:578  
+(::T, ::T) where T\<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}  
@ Base int.jl:87  
+(::T, ::Integer) where T\<:AbstractChar  
@ Base char.jl:237  
…

---

<div class="post-metadata">

**Author:** ![RomeoV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romeov/32/37687_2.png) [@RomeoV](https://discourse.julialang.org/u/RomeoV)\
**Post date:** [November 12, 2023, 1:02am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/2 "2023-11-12T01:02:54Z")

</div>

Your code runs just fine for me.

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [November 12, 2023, 1:10am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/3 "2023-11-12T01:10:28Z")

</div>

You might need to restart Julia. There could be an old function lurking around somewhere in `Base`.

---

<div class="post-metadata">

**Author:** ![RomeoV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romeov/32/37687_2.png) [@RomeoV](https://discourse.julialang.org/u/RomeoV)\
**Post date:** [November 12, 2023, 1:12am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/4 "2023-11-12T01:12:34Z")

</div>

Also, for this particular problem check out [Strings · The Julia Language](https://docs.julialang.org/en/v1/base/strings/#Base.eachmatch).

---

<div class="post-metadata">

**Author:** ![Mohit](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Mohit](https://discourse.julialang.org/u/Mohit)\
**Post date:** [November 12, 2023, 1:15am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/5 "2023-11-12T01:15:51Z")

</div>

Thanks, restart made it work.  
Why it happen, what I can do to prevent it?

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [November 12, 2023, 1:25am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-string-int64/106096/6 "2023-11-12T01:25:40Z")

</div>

Julia’s look-up table for functions is based on the function name as well as the types of the inputs. If you ever change the argument types, both versions will exist and could cause conflicts with each other. Also if your functions are inside of a module, and you import them into Base, then changes to the module won’t be reflected in Base. This particular design decision has caused me to lose a lot of time debugging, personally.

So my recommendation when developing is to wrap your code inside of a module, then import the module, and use module.function to call the function. So for example, if your module is called A and your function is called B, I recommend doing `import A; A.B(...)`.

You can also check whether this is happening by using the `methods` function on your function. So in this case, `methods(oric)` would have revealed more than one signature, if that was the issue.
