ios - Filter an array based on empty value in Swift -


i trying filter array of dictionaries. below code sample of scenario looking for

let names = [      [ "firstname":"chris","middlename":"alex"],     ["firstname":"matt","middlename":""],     ["firstname":"john","middlename":"luke"],     ["firstname":"mary","middlename":"john"], ] 

the final result should array whom there middle name.

this did trick

names.filter {   if let middlename = $0["middlename"] {     return !middlename.isempty   }   return false } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -