Skip to content

Instantly share code, notes, and snippets.

View andr3a88's full-sized avatar

Andrea Stevanato andr3a88

View GitHub Profile
@andr3a88
andr3a88 / loopLabels.swift
Last active January 26, 2016 11:49
Swift Loop Labels
sectionLoop: for section in sections {
rowLoop: for row in rows {
if row.isMagical {
break sectionLoop
}
}
}
@andr3a88
andr3a88 / guard.swift
Last active November 2, 2015 11:49
Swift 2.0 Guard Statement
// Like an if statement, guard executes statements based on a Boolean value of an expression.
// Unlike an if statement, guard statements only run if the conditions are not met.
// You can think of guard more like an Assert, but rather than crashing, you can gracefully exit.
func fooGuardNonOptional(x: Int) {
guard x > 0 else {
// Value requirements not met, do something
return
}