Hey all! I'm extremely new to Zig, and I've found a lot of helpful resources, but I might be overcomplicating this.
What is the best way to write a function that accepts an array of unknown length, does something, and returns them? (Or it could be a pointer)
Something similar to the following:
pub fn main() !void {
const nums = [_]i32{ 3, 4, 5, 6 };
const numsOutput = example(nums);
_ = numsOutput;
}
fn example(nums: []i32) []i32 {
// we would mess with nums a bit here
return nums;
}
Is the best way to do this an Allocator? If so, I can use that; just wondering if I'm overcomplicating this (or missing a better way)
Thanks in advance for any help! ❤️