mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
22 lines
322 B
Zig
22 lines
322 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
const print = std.debug.print;
|
|
|
|
fn deferExample() !usize {
|
|
var a: usize = 1;
|
|
|
|
{
|
|
defer a = 2;
|
|
a = 1;
|
|
}
|
|
try expect(a == 2);
|
|
|
|
a = 5;
|
|
return a;
|
|
}
|
|
|
|
test "defer basics" {
|
|
try expect((try deferExample()) == 5);
|
|
}
|
|
|
|
// test
|