Skip to content

Instantly share code, notes, and snippets.

@chrismsimpson
Last active October 5, 2019 02:13
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 chrismsimpson/22d535b710a01dfab4666c7b26927b2f to your computer and use it in GitHub Desktop.
Save chrismsimpson/22d535b710a01dfab4666c7b26927b2f to your computer and use it in GitHub Desktop.
Collection extensions for Swift
import Foundation
extension Collection {
public var nonEmpty: Self? {
guard !self.isEmpty else {
return nil
}
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment