examples/array/array_argument.ck
raw| 1 | // array pass by reference test |
| 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">>>; |