# ModelingToolkit.jl: '===' comparison on Operations(/Expressions)

**URL:** <https://discourse.julialang.org/t/modelingtoolkit-jl-comparison-on-operations-expressions/45559>\
**Category:** Modelling & Simulations\
**Tags:** symbolic\
**Created:** [August 26, 2020, 8:14am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-comparison-on-operations-expressions/45559 "2020-08-26T08:14:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NumHack](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@NumHack](https://discourse.julialang.org/u/NumHack)\
**Post date:** [August 26, 2020, 8:14am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-comparison-on-operations-expressions/45559/1 "2020-08-26T08:14:33Z")

</div>

Hi,

* * *

## Since this is my first post, I want to thank everyone involved in the creation of the Julia language.

I would like to compare Operation/Expression objects, my initial goal being to replace sub-(Operation/Expression) by another one. I’m having issues understanding the behavior of ‘===’ operator on them :

```julia-auto
using ModelingToolkit

@variables x t
@derivatives D'~t

julia> a=D(x)
derivative(x, t)

julia> b=a # Copy b to a
derivative(x, t)

julia> a==b # '==' operator builds a Symbolic Expression, does not compare Operations.
derivative(x, t) == derivative(x, t)

julia> a===b # Using '===' operator on a and b gives expected result
true

julia> D(x)===D(x) # This does NOT give the expected result
false

```

---

<div class="post-metadata">

**Author:** ![anon37204545](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon37204545](https://discourse.julialang.org/u/anon37204545)\
**Post date:** [August 26, 2020, 10:56am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-comparison-on-operations-expressions/45559/2 "2020-08-26T10:56:14Z")

</div>

Check here:  
[https://stackoverflow.com/questions/38601141/what-is-the-difference-between-and-comparison-operators-in-julia](https://stackoverflow.com/questions/38601141/what-is-the-difference-between-and-comparison-operators-in-julia)

Or here: [Overload === for custom type](https://discourse.julialang.org/t/overload-for-custom-type/4898)

By executing `D(x)` two times you are creating two objects stored at different memory locations. So that behavior is expected.

Since `==` is overloaded, you can use `isequal` instead:

```julia
julia> isequal(D(x), D(x))
true

```

---

<div class="post-metadata">

**Author:** ![NumHack](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@NumHack](https://discourse.julialang.org/u/NumHack)\
**Post date:** [August 26, 2020, 4:24pm UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-comparison-on-operations-expressions/45559/3 "2020-08-26T16:24:10Z")

</div>

I now remember stumbling into isequal() some time ago looking for something else and wrongly though that it was a local package function, not such a fundamental one.

One of the sub-links in the StackOverflow post makes a good summary of it :  
[When should i use `==` vs `===` vs `isequal`](https://stackoverflow.com/questions/57945372/when-should-i-use-vs-vs-isequal?noredirect=1&lq=1)

Thank you very much. 👍
