Created
August 19, 2019 03:20
-
-
Save lainara6-zz/479c98b238911ba4681ecf575ec09ff9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var arrays = [1, 2, 3] | |
| let values = arrays.reduce([:]) { (dictionary, object) -> [String: Int] in | |
| var dic = dictionary | |
| dic["\(object)"] = object | |
| return dic | |
| } | |
| print(values) | |
| var arrays1 = [1, 2, 3] | |
| let values1 = arrays1.reduce([]) { (array, object) -> [[String: Int]] in | |
| var arr = array | |
| var d = [String: Int]() | |
| d["\(object)"] = object | |
| arr.append(d) | |
| return arr | |
| } | |
| print(values1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment