Created
November 14, 2018 03:04
-
-
Save jrfondren/9f79f00f7ae055b5eff647f60e3484e5 to your computer and use it in GitHub Desktop.
concatenating arrays at compile-time
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 warn = std.debug.warn; | |
pub fn main() void { | |
comptime var x1 = []f64{1, 2, 3}; | |
comptime var x2 = x1 ++ x1; // error to assign x1 here | |
comptime var x3 = ([]f64{1, 2, 3})[0..]; | |
x3 = x3 ++ x3; // no error | |
warn("x2: {}\n", @typeName(@typeOf(x2))); | |
warn("x3: {}\n", @typeName(@typeOf(x3))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment