#Can i initialise an array and make it a slice in the same line?

1 messages · Page 1 of 1 (latest)

gritty wigeon
#

I have 2 questions, whats the best way to store a constant value thats an array?

second question being can i initialise an array and make it a slice in the same line:

pub const PREFIX: []u8 = [_]u8{1}[0..];
indigo burrow
#

1: i dont quite get what you mean by "store" but if it's const then just wherever you need it should be fine.

2: pub const PREFIX: []const u8 = &.{ 1, 2, 3 };