Showing the changes to examples/array/array_argument.ck (1 of 486 files). Show all
Unified · Split
| @@ -0,0 +1,19 @@ | ||
| 1 | +// array pass by reference test - should change values? | |
| 2 | + | |
| 3 | +// function that takes array | |
| 4 | +fun void mirror( int arg[] ) | |
| 5 | +{ | |
| 6 | + // assign 0th element to 1st element | |
| 7 | + arg[0] => arg[1]; | |
| 8 | +} | |
| 9 | + | |
| 10 | +// declare array | |
| 11 | +int foo[2]; | |
| 12 | +2 => foo[0]; | |
| 13 | +1 => foo[1]; | |
| 14 | + | |
| 15 | +// call the function | |
| 16 | +mirror( foo ); | |
| 17 | + | |
| 18 | +// test | |
| 19 | +if ( foo[0] == foo[1] ) <<<"success">>>; | |