Why does the following code cause a method error on adding type nothing with an Int?
function flipname(nm)
i = findfirst(isequal(','), nm) # returns type nothing if finds no occurrence
i == nothing ? nm : nm[i+2:length(nm)] * " " * nm[1:i-1]
end
flipname("test")
Meanwhile, the following code behaves as expected:
n = nothing
n == nothing ? println("nothing") : n + 1
There was probably another flipname() method which you had defined previously in that same Jupyter kernel session. For example, you might have had a flipname(nm::AbstractString) or flipname(nm::String), so defining another more general method flipname(nm) would not replace that old method but would happily live alongside it.
This sort of thing is much easier for us to help with if you can post the full error output, including the stack trace, rather than just saying that the code causes an error.