Last active
March 29, 2017 07:27
-
-
Save fitomad/14abd94ed10af84315daccd161111544 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
// 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