Files
sx/examples/04-shadow.sx
2026-02-09 18:07:41 +02:00

21 lines
415 B
Plaintext

#import "modules/std.sx";
main :: () -> s32 {
x := 42;
{
print("scope opened\n");
defer print("scope closed\n");
// define a inner variable x shadowing the one define in the outer scope(s)
x:= 6;
print("scoped x: {}\n", x); //expect 6
}
print("main x: {}\n", x); //expect 42
}
// ** stdout **
// scope opened
// scoped x: 6
// scope closed
// main x: 42
//