# Base.== error

**URL:** <https://discourse.julialang.org/t/base-error/122706>\
**Category:** General Usage\
**Created:** [November 16, 2024, 6:55am UTC](https://discourse.julialang.org/t/base-error/122706 "2024-11-16T06:55:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdo](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@abdo](https://discourse.julialang.org/u/abdo)\
**Post date:** [November 16, 2024, 6:55am UTC](https://discourse.julialang.org/t/base-error/122706/1 "2024-11-16T06:55:38Z")

</div>

Point2D(x::Real, y::Real)

Creates a Point2D object with dimensions x and y  
Can take either two Numbers or a string similat to “(1, 2)”

# Example

julia-repl  
julia\> Point2D(1,2)  
(1, 2)

strng = “(1, -2.4)”  
Point2D(strng)  
(1.0, -2.4)

Point2D((“1, 2”))  
(1, 2)

`mutable struct Point2D`  
` x::Real`  
`y::Rea`l  
` str::String`  
` Point2D(x::Real, y::Real) = new(x, y)`  
` function Point2D(str::String)`  
` idk = match(r"^\(([+-]?\d*\.?\d+?),\s?([+-]?\d*\.?\d+?)\)$", str )`  
` x = parse(Float64, idk[1])`  
` y = parse(Float64, idk[2])`  
` new(x,y)`  
`end`  
`end`  
`Base.show(io::IO,p::Point2D) = print(io, string((p.x,p.y))) #Base.==(p1::Point2D, p2::Point2D) = p1.x == p2.x && p1.y == p2.y Base.==(p1::Point2D, p2::Point2D) = isapprox(p1.x, p2.x) && isapprox(p1.y, p2.y) `

My ‘Base.==’ is giving me an issue :syntax: invalid argument destructuring syntax “(p1::Point2D, p2::Point2D)” around In[9]:9  
trying to use it for test such : @test Point2D(1, 2) == Point2D(1, 2)  
Help!!

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [November 16, 2024, 7:00am UTC](https://discourse.julialang.org/t/base-error/122706/2 "2024-11-16T07:00:32Z")

</div>

Try `Base.:(==) = ...` instead of `Base.==`.

Use triple backtricks to properly quote your quote FYI.

---

<div class="post-metadata">

**Author:** ![abdo](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@abdo](https://discourse.julialang.org/u/abdo)\
**Post date:** [November 16, 2024, 7:12am UTC](https://discourse.julialang.org/t/base-error/122706/3 "2024-11-16T07:12:17Z")

</div>

Thank you, I used Base.:(==)(…)

```julia
Base.:(==)(p1::Point2D, p2::Point2D)= isapprox(p1.x, p2.x) && isapprox(p1.y, p2.y)

```
