Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Tuple in Switch Statement

let info = ("Dwight", 38)

// match complete tuple values
switch info {
  case ("Dwight", 38): 
    print("Dwight is 38 years old")

  case ("Micheal", 46): 
    print("Micheal is 46 years old")

  default:
    print("Not known")
}
Source by www.hackingwithswift.com #
 
PREVIOUS NEXT
Tagged: #Swift #Tuple #Switch #Statement
ADD COMMENT
Topic
Name
6+8 =