Dictionary

Dictionary

Method Overview

NameDescriptionReturn
findKeys()ค้นหา Keys จาก DictionaryArray(Key)
hasKey()ตรวจสอบ Key ใน Dictionary ว่ามีหรือไม่Boolean
merge()รวม Dictionary เข้าด้วยกันโดยยึดค่าจาก Dictionary เป้าหมายเป็นหลักvoid

Method Details

func findKeys(forValue val: Value) -> [Key]

ค้นหา Keys ทั้งหมดจาก Dictionary ด้วย Value

Parameters

NameDescriptionType
forValueValue ที่ต้องการค้นหาใน DictionaryValue

Returns

TypeDescription
Array(Key)Return Keys ที่มี Value ตรงกับ Value ใน Parameters
func findKeys(withoutKey key: Key) -> [Key]

ค้นหา Keys ทั้งหมดจาก Dictionary โดยกรอง Key ที่ไม่ต้องการออก

Parameters

NameDescriptionType
withoutKeyKey ที่ไม่ต้องการใน DictionaryKey

Returns

TypeDescription
Array(Key)Return Keys ที่กรอง Key ที่ไม่ต้องการออก
func findKeys(withoutValue val: Value) -> [Key]

ค้นหา Keys ทั้งหมดจาก Dictionary โดยกรอง Key ที่มี Value เท่ากับ Value ใน Parameters ออก

Parameters

NameDescriptionType
withoutValueValue ที่ไม่ต้องการใน DictionaryValue

Returns

TypeDescription
Array(Key)Return Keys ที่กรอง Key ที่มี Value เท่ากับ Value ใน Parameters ออก
func hasKey(_ key: Key) -> Bool

ตรวจสอบ Key ใน Dictionary ว่ามีหรือไม่

Parameters

NameDescriptionType
keyKey ที่ต้องการตรวจสอบใน DictionaryKey

Returns

TypeDescription
BoolReturn true เมื่อมี Key ใน Dictionary และ Return false เมื่อไม่มี Key ใน Dictionary
mutating func merge(dict: [Key: Value])

รวม Dictionary เข้าด้วยกันโดยยึดค่าจาก Dictionary เป้าหมายเป็นหลัก

Parameters

NameDescriptionType
dictDictionary เป้าหมายที่ต้องการรวมDictionary