Skip to content
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

Dan Meehan solution #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Dan Meehan solution #27

wants to merge 1 commit into from

Conversation

dmee3
Copy link

@dmee3 dmee3 commented May 19, 2017

def edit_beer
id = Print::get_input("\nEnter the id of the beer you want to EDIT:").to_i
b = @beerList.find_beer id
fail "No beer matching id #{id}" unless b
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both calls to find_beer fail when they don't get a result. Should find_beer be responsible for failing when it doesn't find one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, find_beer should probably handle its own failure so there's a single point of failure instead of having to repeat this logic here and in edit_beer on line 41 of the model.

I guess the only reason to return nil and check outside find_beer would be if I wanted to do some other error handling instead of failing right away, which I didn't do anyway haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants