10 posts
Arrays and Slices
Edited by novus1044 on
Hey Bill,

I recently began playing around with Odin and noticed that you have incorporated slices into the language. Do you plan on having arrays automatically coerce into slices when they are passed to procedures? I know Rust does this, and I think it really helps the overall ergonomics of the language.
Ginger Bill
222 posts / 2 projects
I am ginger thus have no soul.
Arrays and Slices
Edited by Ginger Bill on
No. To slice an array, it's really simple:

 1 2 3 4 5 a: [12]int; s: []int; // These too are equivalent s = a[:]; s = a[0:a.count-1]; 

I should note, I may change the syntax eventually from the colon :, to use the same as the for loops: ... and ..<.

This minor syntax difference isn't that important to worry about yet.
10 posts
Arrays and Slices
Edited by novus1044 on
Okay, that makes sense. Without documentation I just wasn't sure how to go about getting a slice from an array.

Thanks for the quick response. Really digging the language so far.