March 2019
Intermediate to advanced
336 pages
9h 9m
English
The swap method takes the elements array and the i and j indices as parameters. The method swaps the element at position i with the element at position j, as shown here:
// swap methodfunc swap(elements []int, i int, j int) { var temp int temp = elements[j] elements[j] = elements[i] elements[i] = temp}
Read now
Unlock full access