| 1 | pub type IntSlice = []int |
| 2 | |
| 3 | pub fn (mut x IntSlice) swap(i int, j int) { |
| 4 | x[i], x[j] = x[j], x[i] |
| 5 | } |
| 6 | |
| 7 | fn test_cross_assign_aliased_array() { |
| 8 | mut x := IntSlice([11, 22]) |
| 9 | println(x) |
| 10 | x.swap(0, 1) |
| 11 | println(x) |
| 12 | assert x == IntSlice([22, 11]) |
| 13 | } |
| 14 | |