Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Modify Tuple Element

// create tuple with two elements
var product = ("MacBook", 1099.99)

print("Original Tuple: ")

// access tuple elements 
print("Name:", product.0)
print("Price:", product.1)

// modify second value
product.1 = 1299.99

print("
Tuple After Modification: ")

// access tuple elements
print("Name:", product.0)
print("Price:", product.1)
 
PREVIOUS NEXT
Tagged: #Swift #Modify #Tuple #Element
ADD COMMENT
Topic
Name
5+1 =