This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vendingMachine = VendingMachine() | |
vendingMachine.coinsDeposited = 8 | |
do { | |
try buyFavoriteSnack(person: "Alice", vendingMachine: vendingMachine) | |
print("Success! Yum.") | |
} catch VendingMachineError.invalidSelection { | |
print("Invalid Selection.") | |
} catch VendingMachineError.outOfStock { | |
print("Out of Stock.") | |
} catch VendingMachineError.insufficientFunds(let coinsNeeded) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Validatable { } | |
extension Int: Validatable { } | |
extension String: Validatable { } | |
protocol ValidatorConvertible { | |
associatedtype ValidationType | |
func validated(_ value: ValidationType) -> Promise<ValidationType> | |
} |