0

Why was "void" inserted?

If I attach the following code to a button

let a := 1;
    if 1 = 1 then
     a := 2
end;
alert(a);
a

it works as expected i.e. 2 is displayed

if I replace "a:=2" by "let a:=2" or "var a:=2" I get

let a := 1;
if 1 = 1 then
    var a := 2;
    void
end;
alert(a);
a

1 is displayed as expected

Why was "void" inserted?

1 reply

null
    • Sean
    • 4 yrs ago
    • Reported - view

    I think the compiler/transpiler is letting you know the code doesn't do anything. I assume this is a test of variable scope. Here's another one :)

     

    let a := 2;
    let b := 3;
    if 1 = 1 then
    let a := 1;
    b := 5
    end;
    alert(a)