Search code examples
juliaoperators

left arrow operator in Julia


I have a vector

a = collect(1:4) 

What is the meaning of a <- a in Julia [result - false]

As per the documentation <- is not an assignment operator in Julia.


Solution

  • Here is a way to check it (so that in the future you will be able to solve similar problems more easily):

    julia> dump(:(a <- a))
    Expr
      head: Symbol call
      args: Array{Any}((3,))
        1: Symbol <
        2: Symbol a
        3: Expr
          head: Symbol call
          args: Array{Any}((2,))
            1: Symbol -
            2: Symbol a
    

    So as you can see a <- a is the same as a < (-a) thus you are comparing, using the < operator the a vector with the -a vector.