feat: add support for arrays
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
[code]
|
||||
foreign fn putchar(c: i32) -> i32;
|
||||
|
||||
fn main() -> i32 {
|
||||
let arr: [i32; 3] = [65, 66, 67];
|
||||
putchar(arr[0]);
|
||||
putchar(arr[1]);
|
||||
putchar(arr[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
[expected_return_code]
|
||||
0
|
||||
|
||||
[expected_output]
|
||||
ABC
|
||||
@@ -0,0 +1,15 @@
|
||||
[code]
|
||||
fn swap(a: *i32, b: *i32) {
|
||||
let temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
fn main() -> i32 {
|
||||
let a = [10, 20];
|
||||
swap(&a[0], &a[1]);
|
||||
return a[0] - a[1]; // 20 - 10 = 10
|
||||
}
|
||||
|
||||
[expected_return_code]
|
||||
10
|
||||
Reference in New Issue
Block a user