Skip to content

Instantly share code, notes, and snippets.

@chuganzy
Last active October 12, 2015 15:56
Show Gist options
  • Save chuganzy/649abb7aa6cea5af6d00 to your computer and use it in GitHub Desktop.
Save chuganzy/649abb7aa6cea5af6d00 to your computer and use it in GitHub Desktop.
struct Person {
let name: String
func isValid() -> Bool {
return !name.characters.isEmpty
}
}
let validPerson = Person(name: "Tom")
let invalidPerson = Person(name: "")
validPerson.isValid() // => true
Person.isValid(validPerson)() // => true
invalidPerson.isValid() // => false
Person.isValid(invalidPerson)() // => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment