Fix Account example #4

Merged
merged 1 commit into from Oct 21, 2015

Projects

None yet

2 participants

@blixt
Contributor
blixt commented Oct 20, 2015

The account example's addFunds was broken (you couldn't add funds to an empty account), this fixes it. I also got a bit (too?) creative and added in an ErrorType to show an excellent use of enum (to throw and catch errors, which could warrant another section perhaps?)

@blixt blixt Fix Account example
The account example's `addFunds` was broken (you couldn't add funds to an empty account), this fixes it. I also got a bit (too?) creative and added in an `ErrorType` to show an excellent use of `enum` (to throw and catch errors, which could warrant another section perhaps?)
8d12543
@terhechte terhechte merged commit 8c5a603 into terhechte:master Oct 21, 2015
@terhechte
Owner

Thanks! Indeed, I had totally forgotten about the ErrorType, obviously a prime example of enum usage. Will fix that. I decided to use the Bool return instead of throws in order to have less complexity in the example, but I suppose it will only confuse people so throwing may be ultimately a better implementation even if it makes the example a bit more complex. Thanks for the PR!

@blixt blixt deleted the blixt:patch-1 branch Oct 21, 2015
@blixt
Contributor
blixt commented Oct 21, 2015

Sounds good, this article is a pretty good read that shows some more uses of enum with errors: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment