나의 발자취
튜플 특징 본문
var easyAsPie = ("easy as", 3.14)
Above, we created easyAsPie that holds 2 values: "easy as", and 3.14. If we wanted to access each value individually, we can use dot syntax along with the index of the value:
var easyAsPie = ("easy as", 3.14)
var firstValue = easyAsPie.0 // "easy as"
var secondValue = easyAsPie.1 // 3.14
var firstValue = easyAsPie.0 // "easy as"
var secondValue = easyAsPie.1 // 3.14
We can also name a tuple’s elements by prepending each one with a name and a colon - similar to key-value pair syntax in dictionaries:
var easyAsPie = (saying: "easy as", amount: 3.14)
var firstElementValue = easyAsPie.saying // "easy as"
var secondElementValue = easyAsPie.amount // 3.14
var firstElementValue = easyAsPie.saying // "easy as"
var secondElementValue = easyAsPie.amount // 3.14
출처:codecademy
'앱 개발 > iOS' 카테고리의 다른 글
Swift 함수 한번에 정리 (0) | 2023.06.30 |
---|---|
if-let 구문, 옵셔널 바인딩 (0) | 2023.06.28 |
View: Vstack, Hstack, Zstack (0) | 2023.06.20 |
SwiftUI View란? View Modifiers (0) | 2023.06.20 |
Switch Statement: Where clause (0) | 2023.06.20 |
Comments