Unexpected handling of "variables" in cmd.exe batch file
I have a `xyz.bat` file with this content:    

    @set val=one
    @if "%val%" equ "one" (
       @set val=yes
       echo val after setting it: %val%
    ) else (
       @set val=no
    )
    @echo %val%

Running it in `cmd.exe` prints

    val after setting it: one
    yes

but I expected

    val after setting it: yes
    yes

Why is this? And is there a way to make it behave as I think it should?
Unexpected handling of "variables" in cmd.exe batch file
===

I have a `xyz.bat` file with this content:    

    @set val=one
    @if "%val%" equ "one" (
       @set val=yes
       echo val after setting it: %val%
    ) else (
       @set val=no
    )
    @echo %val%

Running it in `cmd.exe` prints

    val after setting it: one
    yes

but I expected

    val after setting it: yes
    yes

Why is this? And is there a way to make it behave as I think it should?