Advertisement
Guest User

Untitled

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