-
Notifications
You must be signed in to change notification settings - Fork 17
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
Soda challenge #3
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work. Keep it up. You demonstrate a strong understanding of the material.
if soda != nil | ||
@cash += soda.price | ||
@sodas.delete(soda) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition to the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with reusing the find_soda
method
end | ||
|
||
def find_soda(soda_brand) | ||
@sodas.find{|soda| return soda if soda.brand == soda_brand} | ||
end | ||
|
||
def sell(soda_brand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
end | ||
|
||
def find_soda(soda_brand) | ||
@sodas.find{|soda| return soda if soda.brand == soda_brand} | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be condensed to:
@sodas.find{|soda| soda.brand == soda_brand}
The method find
automatically returns the first match.
No description provided.