Skip to content

Instantly share code, notes, and snippets.

@fitomad
Last active March 29, 2017 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/14abd94ed10af84315daccd161111544 to your computer and use it in GitHub Desktop.
Save fitomad/14abd94ed10af84315daccd161111544 to your computer and use it in GitHub Desktop.
// 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