Comment

Comment by eigenspace

Note if you're doing this in the global scope, the local declaration on `s` will cause it to functionally not exist.

You can write this as either

    s = 0

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

    println("$s")
or

    let s = 0

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

        println("$s")
    end
parent eigenspace 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton