-
-
Save liampwll/f0a9f5a4e95211728483893cb6c23ba9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const S = struct { | |
x: u64, | |
pub fn set(self: *@This(), in: u64) void { | |
self.x = in; | |
} | |
}; | |
var array = comptime blk: { | |
var array3 = [1]S{ S{ .x = 5 }, } ** 2; | |
array3[1].set(7); | |
break :blk array3; | |
}; | |
pub fn main() void { | |
std.debug.warn("{} {}\n", array[0], array[1]); | |
// output is "7 7" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment