# Callback error: " no method matching isless(::Float64, ::Vector{Float64})"

**URL:** https://discourse.julialang.org/t/callback-error-no-method-matching-isless-float64-vector-float64/123476
**Category:** New to Julia
**Tags:** question
**Created:** [December 5, 2024, 1:30am UTC](https://discourse.julialang.org/t/callback-error-no-method-matching-isless-float64-vector-float64/123476 "2024-12-05T01:30:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jordie](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@Jordie](https://discourse.julialang.org/u/Jordie)
#### Post date: [December 5, 2024, 1:30am UTC](https://discourse.julialang.org/t/callback-error-no-method-matching-isless-float64-vector-float64/123476/1 "2024-12-05T01:30:24Z")

</div>

Hi everyone,  
I’m trying to use a callback function. I’m not sure how the callback function works and am trying out this very simple script, but it has not been working. Here is the script:

```julia
### Installs all relevant packages if you don't have them already
using Pkg
function install_package(pkg_name::String)
    if !(pkg_name in keys(Pkg.installed()))
        Pkg.add(pkg_name)
    end
end

packages = [
    "DifferentialEquations",
    "Plots",
    "ModelingToolkit",
    "OrdinaryDiffEq"
]

for pkg in packages
    install_package(pkg)
end

using DifferentialEquations
using Plots
using ModelingToolkit
using OrdinaryDiffEq
###

@variables t x(t)
@independent_variables t
dt = Differential(t)

sys = ODESystem(
    [
        dt(x) ~ -x
    ], 
    t, 
    name=:simple) |> structural_simplify

u₀ = Dict(x => 1.0)  
tspan = (0.0, 5.0)  

callback = DiscreteCallback(
    (t, u, integrator) -> t >= 1.0, 
    (t, u, integrator) -> begin       
        display("The time is over 1 second")
        return true  
    end
    )

# Define and solve the ODE problem
prob = ODEProblem(sys, u₀, tspan)
sol = solve(prob, Tsit5(), callback=callback)

plot(sol)

```

However, I am getting the following error:

```julia
ERROR: MethodError: no method matching isless(::Float64, ::Vector{Float64})
The function `isless` exists, but no method is defined for this combination of argument types.

```

…Which references the “sol” line.  
How can I fix this?

---

<div class="post-metadata">

### Author: ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)
#### Post date: [December 5, 2024, 6:56am UTC](https://discourse.julialang.org/t/callback-error-no-method-matching-isless-float64-vector-float64/123476/2 "2024-12-05T06:56:52Z")

</div>

> [@Jordie](#):
>
> ```julia
> callback = DiscreteCallback(
> (t, u, integrator) -> t >= 1.0, 
> (t, u, integrator) -> begin       
> display("The time is over 1 second")
> return true  
> end
> )
> 
> ```

You’ve got the order of the arguments wrong here. It should be `u, t, integrator`.
