New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Account example #4

Merged
merged 1 commit into from Oct 21, 2015

Conversation

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?)

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?)

terhechte added a commit that referenced this pull request Oct 21, 2015

@terhechte terhechte merged commit 8c5a603 into terhechte:master Oct 21, 2015

@terhechte

This comment has been minimized.

Owner

terhechte commented Oct 21, 2015

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

This comment has been minimized.

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