Variable addition (scope issue)


I have the following code, and it is not working. Why is this?

s = 0
for i = 1:2
    s += i/2


use global s


You haven’t read the scope docs!

s = 0
for i = 1:2
    global s += i/2

Note that this is a controversial new feature of 1.0:


Many thanks.


You should be able to mark a post as “Solved”, so people don’t waste time looking at it.