-
-
Save fitomad/5f1a152f609e998398756e806b5ff876 to your computer and use it in GitHub Desktop.
This file contains 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
let usuarios = [ | |
"Adolfo" : "43", | |
"Carlos" : "10", | |
"Hugo" : "9" | |
] | |
print(usuario) | |
// La salida del terminal es... | |
// ["Hugo": "9", "Carlos": "10", "Adolfo": "43"] | |
// Ahora cambiamos el diccionario para que | |
// los valores sean `Int` y no `String` | |
let edades = usuarios.compactMapValues({ Int($0)}) | |
print("Edades: \(edades)") | |
// La salida del terminal es... | |
// Edades: ["Hugo": 9, "Carlos": 10, "Adolfo": 43] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment