Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let dictionary: [Int: String?] = [1:"one", 2:nil, 3:"three"]
- // It can be taken out as LazyMapCollection. *The order is irregular.
- let underTwoInt = [Int](dictionary.keys.filter { $0 <= 2 }).sort()
- print(underTwoInt) // [1, 2]
- let nonNullString = [String](dictionary.values.flatMap { $0 }).sort()
- print(nonNullString) // ["one", "three"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement