Solution 2: Go Packages and Functions
Let’s solve the challenge set in the previous lesson.
We'll cover the following...
We'll cover the following...
Solution
Here are the two versions of the function that sorts three int values.
Code explanation
Lines 8–29: The
sortIntsfunction takes three integer argumentsa,b, andc, and returns three integers:x,y, andz. The function first creates three local variables—first,second, andthird—to store the sorted values. It then comparesaandb, and the smaller ...