Skip to content

Instantly share code, notes, and snippets.

@fitomad fitomad/swift5_SE-0218.swift Secret
Created Jan 21, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.