Created
May 4, 2015 14:18
-
-
Save vgaltes/eea502a4bc3b2ce9475a to your computer and use it in GitHub Desktop.
FSharp Bank Kata - pattern matching
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
let withdraw amount currency {Amount = (oldAmount, _)} = | |
match oldAmount - amount with | |
| newAmount when newAmount < 0 -> Failure("This bank account cannot be overdrawn.") | |
| newAmount -> Success {Amount = (oldAmount - amount, USD)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment