#array doesn't work

1 messages · Page 1 of 1 (latest)

odd gorge
#
const print = @import("std").debug.print;

pub fn main() !void {

    const array: [3]i8 = [1,2,3];

    print("{d}", .{array})
}
#

why it gives me error ?

quartz orchid
#

The syntax for array initialisation is .{}, not [].

const print = @import("std").debug.print;

pub fn main() !void {
    const array: [3]i8 = .{ 1, 2, 3 };

    print("{d}\n", .{array});
}