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 }