Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed meaning of .+= in Julia 0.5 #6

Open
stevengj opened this issue Jul 21, 2016 · 2 comments
Open

Changed meaning of .+= in Julia 0.5 #6

stevengj opened this issue Jul 21, 2016 · 2 comments

Comments

@stevengj
Copy link

Your code uses x .+= y, so you should know that in Julia 0.5 this has changed meaning to be equivalent to broadcast!(identity, x, x .+ y), so that it mutates the x array (see JuliaLang/julia#17510 … in Julia 0.6 the whole operation will occur in-place without temporaries). So .+ should only be used if the left-hand side is a mutable array, and you don't mind mutating it.

At first glance, this looks like it is okay for you, because you use it in xj[1:n] .+= xj[end], where you are modifying xj in-place anyway. But if it were a problem you could always change it to +=.

@mschauer
Copy link
Owner

mschauer commented Aug 3, 2016

Thank you for the pointer!

@stevengj
Copy link
Author

stevengj commented Aug 3, 2016

Feel free to close if you don't see a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants