Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Números del 0 al 10 pero con el **5** un poco *descolocaldo*
let numeros: [Int] = [ 0, 1, 2, 3, 4, 6, 7, 8, 9, 5, 10 ]
// Swift 3.1
let menores = numeros.prefix(while: { $0 < 5 })
let mayores = numeros.drop(while: { $0 < 5 })
dump(menores)
/*
5 elements
- 0
- 1
- 2
- 3
- 4
*/
dump(mayores)
/*
6 elements
- 6
- 7
- 8
- 9
- 5
- 10
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment