Skip to content

Instantly share code, notes, and snippets.

@jimmythai
Created April 12, 2018 11:41
Show Gist options
  • Select an option

  • Save jimmythai/959b2e977daf32cc1ce936db79b32935 to your computer and use it in GitHub Desktop.

Select an option

Save jimmythai/959b2e977daf32cc1ce936db79b32935 to your computer and use it in GitHub Desktop.
// Somthing like this:
var current = 1
while current * current <= 100 {
current += 1
}
result = current * current
// To this:
let result = (1...)
.lazy
.map { $0 * $0 }
.first(where: { $0 > 100})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment