Extend Base.&

Is it possible to extend Base.&.

i.e.

function &(my_stuct_a, my_struct_b)
    # Some Code
end

It throws error

ERROR: syntax: expected "(" in function definition

And then, attempting

function Base.&(my_stuct_a, my_struct_b)
    # Some Code
end

Error: syntax: expected "end" in definition of function  "Base"
1 Like

Yes, but you need to have Base.:& for it to work.

3 Likes

yes,
but you should import it first

julia> import Base: (&)

julia> function (&)(my_stuct_a, my_struct_b)
# some code
end
& (generic function with 17 methods)

You can also do:

function Base.:&(a::String, b::String)
...
end