Skip to content

Instantly share code, notes, and snippets.

@liampwll

liampwll/bug.zig Secret

Created July 18, 2019 05:30
Show Gist options
  • Save liampwll/f0a9f5a4e95211728483893cb6c23ba9 to your computer and use it in GitHub Desktop.
Save liampwll/f0a9f5a4e95211728483893cb6c23ba9 to your computer and use it in GitHub Desktop.
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