-
Notifications
You must be signed in to change notification settings - Fork 14
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
Coral Ruschak #13
base: main
Are you sure you want to change the base?
Coral Ruschak #13
Conversation
@names = [] | ||
@food_trucks.each do |truck| | ||
@names << truck.name | ||
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 is returning all food trucks because each
returns the original array.
lib/event.rb
Outdated
|
||
def food_trucks_that_sell(item) | ||
@food_trucks.find_all do |truck| | ||
truck.inventory[:item] == item |
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.
The key :item
will not exist in your hash, you should be looking for the key item
(the argument that you are sending in to the method.
@inventory = {} | ||
end | ||
|
||
def check_stock(item) |
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 logic will not work in the situations where the inventory hash is not empty, but does not contain the requested item.
The method is also not working because you are looking for the wrong key. You should be looking for the key item
lib/food_truck.rb
Outdated
end | ||
|
||
def stock(item, amount) | ||
@inventory[item] += amount |
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 would only work if an item already exists in the @inventory hash. But, since this method is the way that we get things into that hash.... that will never work. You are trying to do math on nil
…r a FoodTruck object based on inventory
…tements & addressed review comments on food_trucks_that_sell(item) method
No description provided.