How do I dot-assign to a returned value using `@.`?

Let’s create 2 arrays first:

julia> a = rand(100); b = rand(100)

Take identity(a) as an example. These works:

  • identity(a) .= b
  • identity(a) .+= b
  • @. $identity(a) += b
  • x = identity(a); @. x = b

But this doesn’t:

julia> @. $identity(a) = b
ERROR: syntax: invalid function name "$identity" around REPL[69]:1

Seems that Julia thinks I’m defining a function called $identity.

Try @. $(identity(a)) = b

1 Like

It works. Thanks!