Skip to content

Instantly share code, notes, and snippets.

@helloworldsmart
Last active November 5, 2016 10:08
Show Gist options
  • Select an option

  • Save helloworldsmart/28465388bf6847a45fcd6f7af9f34e9d to your computer and use it in GitHub Desktop.

Select an option

Save helloworldsmart/28465388bf6847a45fcd6f7af9f34e9d to your computer and use it in GitHub Desktop.
inout便利貼
//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