로딩
요청 처리 중입니다...

[Swift] Collection Type - Set

 [Swift] Collection Type - Set

다른 언어와 달리 스위프트의 경우 자료형은 Array, Set, Dictionary가 기본형으로 사용되는데 Set An unordered collection of unique elements 라고 Apple 개발자 문서에 설명이 되어있다. 즉 순서를 가지지 않는다. let ingredients: Set = ["cocoa beans", "sugar", "cocoa butter", "salt"] if ingredients.contains("sugar") { print("No thanks, too sweet.") } // Prints "No thanks, too sweet."

이와 관련되어 내부 요소를 확인하고 체크하는 함수는 ingredients.contains(_:) //method to test whether a set contains a specific elements ingredients.isSubset(of:) //methods to test whether a set conta...