Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

Fix Account example #4

Merged
merged 1 commit into from
Oct 21, 2015
Merged

Fix Account example #4

merged 1 commit into from
Oct 21, 2015

Conversation

blixt
Copy link
Contributor

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

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
Copy link
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 patch-1 branch October 21, 2015 13:30
@blixt
Copy link
Contributor Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants