하핫 앙녕 상남자 Philip입니당 데헷 - tuple decomposition
본문 바로가기

ios Development/Swift

tuple decomposition

// tuple decomposition = 튜플 분해


let anything = ("person", 400, "John", "mingu", 10.24)


// use tuple decomposition

let (type, age, who, genius, IQ) = anything


// if use decomposition, no need to call it such as anything.type or anything.age

simply call it by their names. since we gave them names.


example :

print (type)                                 ---------> "person"

print (genius)                              ---------> "mingu"


EASY



'ios Development > Swift' 카테고리의 다른 글

String interpolation  (0) 2020.01.09
tuple matching  (0) 2020.01.08
unnamed tuple, named tuple  (0) 2020.01.08
syntax optimization 스위프트 문법 최적화 closure  (0) 2020.01.08
while 반복문의 두가지  (0) 2020.01.04