Last active
April 25, 2020 06:12
-
-
Save AppleCEO/f0bf7437f78c7e2577500425c4e1c57c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func swapTwoIntsWithInout(a: inout Int, b: inout Int) { | |
let temporaryA = a | |
a = b | |
b = temporaryA | |
} | |
var firstNumber = 10 | |
var secondNumber = 30 | |
print("firstNumber : \(firstNumber)") // 10 | |
print("secondNumber : \(secondNumber)") // 30 | |
swapTwoIntsWithInout(a: &firstNumber, b: &secondNumber) | |
print("firstNumber : \(firstNumber)") // 30 | |
print("secondNumber : \(secondNumber)") // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment