Skip to content

Instantly share code, notes, and snippets.

@bryanluby
Last active June 1, 2023 16:10
Show Gist options
  • Save bryanluby/fd5ac0a8c74c2c3241d9 to your computer and use it in GitHub Desktop.
Save bryanluby/fd5ac0a8c74c2c3241d9 to your computer and use it in GitHub Desktop.
Switch on indexPath using tuple example in Swift.
switch (indexPath.section, indexPath.row) {
case (0, _): println("section 0")
case (1, _): println("section 1")
case (2, 0...2): println("section 2 0-2")
case (2, 3...5): println("section 2 3-5")
case (3, let row): println("\(row)")
default: println("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment