Technically, this is not guaranteed to preserve order, but it does.
Dictionary(grouping: numbers) { $0.isMultiple(of: 3) }
https://github.com/apple/swift/blob/master/stdlib/public/core/NativeDictionary.swift
More Related Contents:
- How do I shuffle an array in Swift?
- Get random elements from array in Swift
- Why isn’t [SomeStruct] convertible to [Any]?
- How can I extend typed Arrays in Swift?
- Sort Objects in Array by date
- Sorting a Swift array by ordering from another array
- Confused about Swift Array Declarations
- Finding sum of elements in Swift array
- Swift 3.0: compiler error when calling global func min(T,T) in Array or Dictionary extension
- Swift JSONDecode decoding arrays fails if single element decoding fails
- How do I sort a swift array containing instances of NSManagedObject subclass by an attribute value (date)
- How do I make a exact duplicate copy of an array?
- Adding items to Swift array across multiple threads causing issues (because arrays aren’t thread safe) – how do I get around that?
- Count the occurences a particular integer has in an array [duplicate]
- Find min / max value in Swift Array
- type any? has no subscript members
- Creating an extension to filter nils from an Array in Swift
- Convert bytes/UInt8 array to Int in Swift
- Compare arrays in swift
- How do you create an immutable array in Swift?
- Is there a way to instantly generate an array filled with a range of values in Swift?
- Generic function to sort array of class or struct by properties in Swift
- How can I decode a JSON response with an unknown key in Swift?
- How to merge two arrays in Swift
- New Array from Index Range Swift
- Iterate over two arrays simultaneously
- Why does the reverse() function in the Swift standard library return ReverseRandomAccessCollection?
- Compare 2 arrays and list the differences – Swift
- In Swift how can I sort one array based on another array?
- check if all elements of an array have the same value in Swift