Skip to content

Instantly share code, notes, and snippets.

@RPallas92
Created September 24, 2017 11:45
Show Gist options
  • Save RPallas92/27b0371389fc7ebbeafd76d007ceff8d to your computer and use it in GitHub Desktop.
Save RPallas92/27b0371389fc7ebbeafd76d007ceff8d to your computer and use it in GitHub Desktop.
//You can react to the validation result value, either it's a success or a failure
let success: Validation<String, Int> = Validation.Success(1)
switch(success){
case .Success(let value):
print(value)
case .Failure(let error):
print(error)
}
// ==> Print(1)
let failure: Validation<String, Int> = Validation.Failure("error")
switch(failure){
case .Success(let value):
print(value)
case .Failure(let error):
print(error)
}
// ==> Print("error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment