Skip to content

Instantly share code, notes, and snippets.

@jakehawken
Created March 14, 2018 04:54
Show Gist options
  • Select an option

  • Save jakehawken/023ae48370a218095ab70e6510ab37b0 to your computer and use it in GitHub Desktop.

Select an option

Save jakehawken/023ae48370a218095ab70e6510ab37b0 to your computer and use it in GitHub Desktop.
.asSet() and .asArray() -- Why don't these already exist?
extension Array where Element: Hashable {
func asSet() -> Set<Element> {
return Set(self)
}
}
extension Set {
func asArray() -> [Element] {
return Array(self)
}
}
@jakebromberg
Copy link

Why not just use the provided initializers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment