Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Another alternative is putting the code in a function and calling that function.

    function test()
        s = 0

        for i = 1:10
           t = s + i
           s = t
           println("$s")
        end

        println("$s")
    end

    test()
For anyone curious, the rationale for this scoping is explained in the docs. Essentially it's to prevent the so-called spooky action at distance.


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: