Skip to content

Instantly share code, notes, and snippets.

@regnerjr
Created March 26, 2015 22:46
Show Gist options
  • Save regnerjr/460e48dfc9c526b20a2f to your computer and use it in GitHub Desktop.
Save regnerjr/460e48dfc9c526b20a2f to your computer and use it in GitHub Desktop.
//Turns out in swift Bool is a struct!
/// From the Docs. `import Swift`
/// A value type whose instances are either `true` or `false`.
struct Bool {
/// Default-initialize Boolean value to `false`.
init()
}
// This means that if you try to switch on a Bool You must provide a default case.
switch tooSmallToSort {
case true: return a
case false: return a.reduce([a.first!], combine: _uniq)
}
// tooSmallToSort is a Bool, but we get a compiler error at the last brace urging us to add a default case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment