Last active
November 5, 2016 10:08
-
-
Save helloworldsmart/28465388bf6847a45fcd6f7af9f34e9d to your computer and use it in GitHub Desktop.
inout便利貼
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
| //inout類似C++傳遞引用 | |
| var image = [ | |
| [3, 7, 10], | |
| [6, 4, 2], | |
| [8, 5, 4] | |
| ] | |
| func raiseLowerValueOfImage(_ image:inout [[Int]]) { | |
| for row in 0..<image.count { | |
| for color in 0..<image[row].count { | |
| image[row][color] | |
| if (image[row][color] < 5) { | |
| image[row][color] = 5 | |
| } | |
| } | |
| } | |
| image | |
| } | |
| raiseLowerValueOfImage(&image) | |
| image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment