Does "while" start a new scope now?

Hello,
Does “while” start a new scope now?
Below code was not working without global y definition?
Am I wrong?

function f3()
        y=0
        while y<5
                y=y+1
                print("f3: y=",y,"\n")        
        end
end

Yes it does, but in a function it should still use the one from the containing scope. Which version are you running? The code works for me, but only after fixing your broken " in the print statement (notice how they are differing later in the same line).

By the way, you can create code blocks in Discourse by wrapping your code in triple backticks (```).

1 Like

Sorry I couldn’t remember back ticks.

Was it doing after ver 1.0.0 (2018-08-08)? May be I remember wrong…

I’ve just tested it on both 0.7 and 1.0, both worked fine for me.

1 Like

Ok thank you.

This means I need a holiday…